annotate src/gui_haiku.cc @ 20152:bac01efdf059 v8.2.0631

patch 8.2.0631: Haiku file formatted with wrong tabstop Commit: https://github.com/vim/vim/commit/b52575f9cfcb5c9715ed08ccd552a55e0052370e Author: Bram Moolenaar <Bram@vim.org> Date: Fri Apr 24 22:16:13 2020 +0200 patch 8.2.0631: Haiku file formatted with wrong tabstop Problem: Haiku file formatted with wrong tabstop. Solution: Use normal tabstop. Fix white space.
author Bram Moolenaar <Bram@vim.org>
date Fri, 24 Apr 2020 22:30:03 +0200
parents 352701a626ed
children 993d820196b9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4:
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2 *
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
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
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 *
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 * Do ":help uganda" in Vim to read copying and usage conditions.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 * Do ":help credits" in Vim to see a list of people who contributed.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 *
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 * Based on "GUI support for the Buzzword Enhanced Operating System."
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 *
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 * Ported to R4 by Richard Offer <richard@whitequeen.com> Jul 99
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13 *
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 * Haiku support by Siarzhuk Zharski <imker@gmx.li> Apr-Mai 2009
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15 *
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 * Structure of the Haiku GUI code:
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 *
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 * There are 3 threads.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 * 1. The initial thread. In gui_mch_prepare() this gets to run the
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 * BApplication message loop. But before it starts doing that,
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 * it creates thread 2
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 * 2. The main() thread. This thread is created in gui_mch_prepare()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 * and its purpose in life is to call main(argc, argv) again.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 * This thread is doing the bulk of the work.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 * 3. Sooner or later, a window is opened by the main() thread. This
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 * causes a second message loop to be created: the window thread.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 *
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 * == alternatively ===
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 *
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 * #if RUN_BAPPLICATION_IN_NEW_THREAD...
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 *
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 * 1. The initial thread. In gui_mch_prepare() this gets to spawn
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 * thread 2. After doing that, it returns to main() to do the
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 * bulk of the work, being the main() thread.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 * 2. Runs the BApplication.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 * 3. The window thread, just like in the first case.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 *
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 * This second alternative is cleaner from Vim's viewpoint. However,
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 * the BeBook seems to assume everywhere that the BApplication *must*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 * run in the initial thread. So perhaps doing otherwise is very wrong.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 *
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 * However, from a B_SINGLE_LAUNCH viewpoint, the first is better.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 * If Vim is marked "Single Launch" in its application resources,
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 * and a file is dropped on the Vim icon, and another Vim is already
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 * running, the file is passed on to the earlier Vim. This happens
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 * in BApplication::Run(). So we want Vim to terminate if
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 * BApplication::Run() terminates. (See the BeBook, on BApplication.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 * However, it seems that the second copy of Vim isn't even started
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 * in this case... which is for the better since I wouldn't know how
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 * to detect this case.)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 *
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 * Communication between these threads occurs mostly by translating
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 * BMessages that come in and posting an appropriate translation on
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 * the VDCMP (Vim Direct Communication Message Port). Therefore the
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 * actions required for keypresses and window resizes, etc, are mostly
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59 * performed in the main() thread.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 *
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 * A notable exception to this is the Draw() event. The redrawing of
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 * the window contents is performed asynchronously from the window
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 * thread. To make this work correctly, a locking protocol is used when
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64 * any thread is accessing the essential variables that are used by
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 * the window thread.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66 *
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 * This locking protocol consists of locking Vim's window. This is both
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 * convenient and necessary.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71 extern "C" {
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 #include <assert.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 #include <float.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 #include <syslog.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77 #include "vim.h"
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 #include "globals.h"
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 #include "proto.h"
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 #include "version.h"
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
82 } // extern "C"
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 // ---------------- start of header part ----------------
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86 //#include <Alert.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87 #include <Application.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88 #include <Beep.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 #include <Bitmap.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90 #include <Box.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 #include <Button.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 #include <Clipboard.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93 #include <Debug.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 //#include <Directory.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95 //#include <Entry.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 #include <File.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 #include <FilePanel.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98 #include <FindDirectory.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99 //#include <Font.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100 #include <IconUtils.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 #include <Input.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102 #include <ListView.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
103 #include <MenuBar.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
104 #include <MenuItem.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105 //#include <MessageQueue.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
106 //#include <OS.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107 #include <Path.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108 #include <PictureButton.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109 #include <PopUpMenu.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
110 //#include <Region.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
111 #include <Resources.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112 //#include <Roster.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113 #include <Screen.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
114 #include <ScrollBar.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
115 #include <ScrollView.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116 #include <String.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
117 #include <StringView.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118 //#include <SupportDefs.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119 #include <TabView.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
120 #include <TextControl.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
121 #include <TextView.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
122 #include <TranslationUtils.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
123 #include <TranslatorFormats.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
124 #include <View.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
125 #include <Window.h>
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
126
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
127 class VimApp;
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
128 class VimFormView;
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
129 class VimTextAreaView;
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
130 class VimWindow;
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
131 class VimToolbar;
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
132 class VimTabLine;
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
133
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
134 extern key_map *keyMap;
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
135 extern char *keyMapChars;
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
136
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
137 extern int main(int argc, char **argv);
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
138
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
139 #ifndef B_MAX_PORT_COUNT
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
140 #define B_MAX_PORT_COUNT 255
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
141 #endif
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
142
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
143 // VimApp seems comparable to the X "vimShell"
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
144 class VimApp: public BApplication
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
145 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
146 typedef BApplication Inherited;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
147 public:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
148 VimApp(const char *appsig);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
149 ~VimApp();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
150
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
151 // callbacks:
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
152 #if 0
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
153 virtual void DispatchMessage(BMessage *m, BHandler *h)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
154 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
155 m->PrintToStream();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
156 Inherited::DispatchMessage(m, h);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
157 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
158 #endif
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
159 virtual void ReadyToRun();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
160 virtual void ArgvReceived(int32 argc, char **argv);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
161 virtual void RefsReceived(BMessage *m);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
162 virtual bool QuitRequested();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
163 virtual void MessageReceived(BMessage *m);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
164
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
165 static void SendRefs(BMessage *m, bool changedir);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
166
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
167 sem_id fFilePanelSem;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
168 BFilePanel* fFilePanel;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
169 BPath fBrowsedPath;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
170 private:
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
171 };
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
172
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
173 class VimWindow: public BWindow
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
174 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
175 typedef BWindow Inherited;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
176 public:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
177 VimWindow();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
178 ~VimWindow();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
179
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
180 // virtual void DispatchMessage(BMessage *m, BHandler *h);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
181 virtual void WindowActivated(bool active);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
182 virtual bool QuitRequested();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
183
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
184 VimFormView *formView;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
185
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
186 private:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
187 void init();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
188
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
189 };
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
190
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
191 class VimFormView: public BView
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
192 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
193 typedef BView Inherited;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
194 public:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
195 VimFormView(BRect frame);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
196 ~VimFormView();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
197
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
198 // callbacks:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
199 virtual void AllAttached();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
200 virtual void FrameResized(float new_width, float new_height);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
201
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
202 #define MENUBAR_MARGIN 1
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
203 float MenuHeight() const
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
204 { return menuBar ? menuBar->Frame().Height() + MENUBAR_MARGIN: 0; }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
205 BMenuBar *MenuBar() const
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
206 { return menuBar; }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
207
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
208 private:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
209 void init(BRect);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
210
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
211 BMenuBar *menuBar;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
212 VimTextAreaView *textArea;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
213
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
214 #ifdef FEAT_TOOLBAR
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
215 public:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
216 float ToolbarHeight() const;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
217 VimToolbar *ToolBar() const
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
218 { return toolBar; }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
219 private:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
220 VimToolbar *toolBar;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
221 #endif
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
222
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
223 #ifdef FEAT_GUI_TABLINE
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
224 public:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
225 VimTabLine *TabLine() const { return tabLine; }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
226 bool IsShowingTabLine() const { return showingTabLine; }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
227 void SetShowingTabLine(bool showing) { showingTabLine = showing; }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
228 float TablineHeight() const;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
229 private:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
230 VimTabLine *tabLine;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
231 int showingTabLine;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
232 #endif
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
233 };
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
234
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
235 class VimTextAreaView: public BView
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
236 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
237 typedef BView Inherited;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
238 public:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
239 VimTextAreaView(BRect frame);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
240 ~VimTextAreaView();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
241
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
242 // callbacks:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
243 virtual void Draw(BRect updateRect);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
244 virtual void KeyDown(const char *bytes, int32 numBytes);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
245 virtual void MouseDown(BPoint point);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
246 virtual void MouseUp(BPoint point);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
247 virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *message);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
248 virtual void MessageReceived(BMessage *m);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
249
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
250 // own functions:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
251 int mchInitFont(char_u *name);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
252 void mchDrawString(int row, int col, char_u *s, int len, int flags);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
253 void mchClearBlock(int row1, int col1, int row2, int col2);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
254 void mchClearAll();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
255 void mchDeleteLines(int row, int num_lines);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
256 void mchInsertLines(int row, int num_lines);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
257
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
258 static void guiSendMouseEvent(int button, int x, int y, int repeated_click, int_u modifiers);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
259 static void guiMouseMoved(int x, int y);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
260 static void guiBlankMouse(bool should_hide);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
261 static int_u mouseModifiersToVim(int32 beModifiers);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
262
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
263 int32 mouseDragEventCount;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
264
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
265 #ifdef FEAT_MBYTE_IME
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
266 void DrawIMString(void);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
267 #endif
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
268
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
269 private:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
270 void init(BRect);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
271
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
272 int_u vimMouseButton;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
273 int_u vimMouseModifiers;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
274
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
275 #ifdef FEAT_MBYTE_IME
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
276 struct {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
277 BMessenger* messenger;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
278 BMessage* message;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
279 BPoint location;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
280 int row;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
281 int col;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
282 int count;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
283 } IMData;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
284 #endif
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
285 };
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
286
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
287 class VimScrollBar: public BScrollBar
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
288 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
289 typedef BScrollBar Inherited;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
290 public:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
291 VimScrollBar(scrollbar_T *gsb, orientation posture);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
292 ~VimScrollBar();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
293
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
294 virtual void ValueChanged(float newValue);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
295 virtual void MouseUp(BPoint where);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
296 void SetValue(float newval);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
297 scrollbar_T *getGsb()
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
298 { return gsb; }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
299
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
300 int32 scrollEventCount;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
301
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
302 private:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
303 scrollbar_T *gsb;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
304 float ignoreValue;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
305 };
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
306
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
307
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
308 #ifdef FEAT_TOOLBAR
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
309
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
310 class VimToolbar : public BBox
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
311 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
312 static BBitmap *normalButtonsBitmap;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
313 static BBitmap *grayedButtonsBitmap;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
314
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
315 BBitmap *LoadVimBitmap(const char* fileName);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
316 bool GetPictureFromBitmap(BPicture *pictureTo, int32 index, BBitmap *bitmapFrom, bool pressed);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
317 bool ModifyBitmapToGrayed(BBitmap *bitmap);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
318
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
319 BList fButtonsList;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
320 void InvalidateLayout();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
321
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
322 public:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
323 VimToolbar(BRect frame, const char * name);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
324 ~VimToolbar();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
325
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
326 bool PrepareButtonBitmaps();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
327
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
328 bool AddButton(int32 index, vimmenu_T *menu);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
329 bool RemoveButton(vimmenu_T *menu);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
330 bool GrayButton(vimmenu_T *menu, int grey);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
331
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
332 float ToolbarHeight() const;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
333 virtual void AttachedToWindow();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
334 };
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
335
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
336 BBitmap *VimToolbar::normalButtonsBitmap = NULL;
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
337 BBitmap *VimToolbar::grayedButtonsBitmap = NULL;
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
338
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
339 const float ToolbarMargin = 3.;
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
340 const float ButtonMargin = 3.;
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
341
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
342 #endif //FEAT_TOOLBAR
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
343
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
344 #ifdef FEAT_GUI_TABLINE
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
345
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
346 class VimTabLine : public BTabView
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
347 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
348 public:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
349 class VimTab : public BTab {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
350 public:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
351 VimTab() : BTab(new BView(BRect(), "-Empty-", 0, 0)) {}
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
352
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
353 virtual void Select(BView* owner);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
354 };
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
355
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
356 VimTabLine(BRect r) : BTabView(r, "vimTabLine", B_WIDTH_FROM_LABEL,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
357 B_FOLLOW_LEFT | B_FOLLOW_TOP | B_FOLLOW_RIGHT, B_WILL_DRAW | B_FRAME_EVENTS) {}
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
358
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
359 float TablineHeight() const;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
360 virtual void MouseDown(BPoint point);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
361 };
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
362
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
363 #endif //FEAT_GUI_TABLINE
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
364
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
365
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
366 // For caching the fonts that are used;
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
367 // Vim seems rather sloppy in this regard.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
368 class VimFont: public BFont
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
369 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
370 typedef BFont Inherited;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
371 public:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
372 VimFont();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
373 VimFont(const VimFont *rhs);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
374 VimFont(const BFont *rhs);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
375 VimFont(const VimFont &rhs);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
376 ~VimFont();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
377
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
378 VimFont *next;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
379 int refcount;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
380 char_u *name;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
381
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
382 private:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
383 void init();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
384 };
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
385
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
386 #if defined(FEAT_GUI_DIALOG)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
387
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
388 class VimDialog : public BWindow
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
389 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
390 typedef BWindow Inherited;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
391
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
392 BButton* _CreateButton(int32 which, const char* label);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
393
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
394 public:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
395
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
396 class View : public BView {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
397 typedef BView Inherited;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
398
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
399 public:
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
400 View(BRect frame);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
401 ~View();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
402
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
403 virtual void Draw(BRect updateRect);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
404 void InitIcon(int32 type);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
405
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
406 private:
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
407 BBitmap* fIconBitmap;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
408 };
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
409
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
410 VimDialog(int type, const char *title, const char *message,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
411 const char *buttons, int dfltbutton, const char *textfield,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
412 int ex_cmd);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
413 ~VimDialog();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
414
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
415 int Go();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
416
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
417 virtual void MessageReceived(BMessage *msg);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
418
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
419 private:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
420 sem_id fDialogSem;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
421 int fDialogValue;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
422 BList fButtonsList;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
423 BTextView* fMessageView;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
424 BTextControl* fInputControl;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
425 const char* fInputValue;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
426 };
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
427
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
428 class VimSelectFontDialog : public BWindow
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
429 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
430 typedef BWindow Inherited;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
431
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
432 void _CleanList(BListView* list);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
433 void _UpdateFontStyles();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
434 void _UpdateSizeInputPreview();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
435 void _UpdateFontPreview();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
436 bool _UpdateFromListItem(BListView* list, char* text, int textSize);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
437 public:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
438
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
439 VimSelectFontDialog(font_family* family, font_style* style, float* size);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
440 ~VimSelectFontDialog();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
441
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
442 bool Go();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
443
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
444 virtual void MessageReceived(BMessage *msg);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
445
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
446 private:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
447 status_t fStatus;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
448 sem_id fDialogSem;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
449 bool fDialogValue;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
450 font_family* fFamily;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
451 font_style* fStyle;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
452 float* fSize;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
453 font_family fFontFamily;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
454 font_style fFontStyle;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
455 float fFontSize;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
456 BStringView* fPreview;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
457 BListView* fFamiliesList;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
458 BListView* fStylesList;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
459 BListView* fSizesList;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
460 BTextControl* fSizesInput;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
461 };
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
462
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
463 #endif // FEAT_GUI_DIALOG
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
464
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
465 // ---------------- end of GUI classes ----------------
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
466
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
467 struct MainArgs {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
468 int argc;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
469 char **argv;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
470 };
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
471
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
472 // These messages are copied through the VDCMP.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
473 // Therefore they ought not to have anything fancy.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
474 // They must be of POD type (Plain Old Data)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
475 // as the C++ standard calls them.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
476
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
477 #define KEY_MSG_BUFSIZ 7
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
478 #if KEY_MSG_BUFSIZ < MAX_KEY_CODE_LEN
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
479 #error Increase KEY_MSG_BUFSIZ!
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
480 #endif
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
481
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
482 struct VimKeyMsg {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
483 char_u length;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
484 char_u chars[KEY_MSG_BUFSIZ]; // contains Vim encoding
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
485 bool csi_escape;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
486 };
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
487
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
488 struct VimResizeMsg {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
489 int width;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
490 int height;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
491 };
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
492
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
493 struct VimScrollBarMsg {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
494 VimScrollBar *sb;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
495 long value;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
496 int stillDragging;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
497 };
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
498
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
499 struct VimMenuMsg {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
500 vimmenu_T *guiMenu;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
501 };
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
502
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
503 struct VimMouseMsg {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
504 int button;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
505 int x;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
506 int y;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
507 int repeated_click;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
508 int_u modifiers;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
509 };
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
510
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
511 struct VimMouseMovedMsg {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
512 int x;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
513 int y;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
514 };
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
515
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
516 struct VimFocusMsg {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
517 bool active;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
518 };
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
519
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
520 struct VimRefsMsg {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
521 BMessage *message;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
522 bool changedir;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
523 };
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
524
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
525 struct VimTablineMsg {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
526 int index;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
527 };
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
528
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
529 struct VimTablineMenuMsg {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
530 int index;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
531 int event;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
532 };
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
533
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
534 struct VimMsg {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
535 enum VimMsgType {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
536 Key, Resize, ScrollBar, Menu, Mouse, MouseMoved, Focus, Refs, Tabline, TablineMenu
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
537 };
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
538
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
539 union {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
540 struct VimKeyMsg Key;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
541 struct VimResizeMsg NewSize;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
542 struct VimScrollBarMsg Scroll;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
543 struct VimMenuMsg Menu;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
544 struct VimMouseMsg Mouse;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
545 struct VimMouseMovedMsg MouseMoved;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
546 struct VimFocusMsg Focus;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
547 struct VimRefsMsg Refs;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
548 struct VimTablineMsg Tabline;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
549 struct VimTablineMenuMsg TablineMenu;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
550 } u;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
551 };
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
552
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
553 #define RGB(r, g, b) ((char_u)(r) << 16 | (char_u)(g) << 8 | (char_u)(b) << 0)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
554 #define GUI_TO_RGB(g) { (g) >> 16, (g) >> 8, (g) >> 0, 255 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
555
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
556 // ---------------- end of header part ----------------
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
557
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
558 static struct specialkey
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
559 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
560 uint16 BeKeys;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
561 #define KEY(a,b) ((a)<<8|(b))
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
562 #define K(a) KEY(0,a) // for ASCII codes
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
563 #define F(b) KEY(1,b) // for scancodes
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
564 char_u vim_code0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
565 char_u vim_code1;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
566 } special_keys[] =
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
567 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
568 {K(B_UP_ARROW), 'k', 'u'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
569 {K(B_DOWN_ARROW), 'k', 'd'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
570 {K(B_LEFT_ARROW), 'k', 'l'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
571 {K(B_RIGHT_ARROW), 'k', 'r'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
572 {K(B_BACKSPACE), 'k', 'b'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
573 {K(B_INSERT), 'k', 'I'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
574 {K(B_DELETE), 'k', 'D'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
575 {K(B_HOME), 'k', 'h'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
576 {K(B_END), '@', '7'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
577 {K(B_PAGE_UP), 'k', 'P'}, // XK_Prior
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
578 {K(B_PAGE_DOWN), 'k', 'N'}, // XK_Next,
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
579
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
580 #define FIRST_FUNCTION_KEY 11
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
581 {F(B_F1_KEY), 'k', '1'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
582 {F(B_F2_KEY), 'k', '2'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
583 {F(B_F3_KEY), 'k', '3'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
584 {F(B_F4_KEY), 'k', '4'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
585 {F(B_F5_KEY), 'k', '5'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
586 {F(B_F6_KEY), 'k', '6'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
587 {F(B_F7_KEY), 'k', '7'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
588 {F(B_F8_KEY), 'k', '8'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
589 {F(B_F9_KEY), 'k', '9'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
590 {F(B_F10_KEY), 'k', ';'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
591
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
592 {F(B_F11_KEY), 'F', '1'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
593 {F(B_F12_KEY), 'F', '2'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
594 // {XK_F13, 'F', '3'}, // would be print screen
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
595 // sysreq
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
596 {F(0x0F), 'F', '4'}, // scroll lock
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
597 {F(0x10), 'F', '5'}, // pause/break
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
598 // {XK_F16, 'F', '6'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
599 // {XK_F17, 'F', '7'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
600 // {XK_F18, 'F', '8'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
601 // {XK_F19, 'F', '9'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
602 // {XK_F20, 'F', 'A'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
603 // {XK_F21, 'F', 'B'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
604 // {XK_F22, 'F', 'C'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
605 // {XK_F23, 'F', 'D'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
606 // {XK_F24, 'F', 'E'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
607 // {XK_F25, 'F', 'F'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
608 // {XK_F26, 'F', 'G'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
609 // {XK_F27, 'F', 'H'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
610 // {XK_F28, 'F', 'I'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
611 // {XK_F29, 'F', 'J'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
612 // {XK_F30, 'F', 'K'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
613 // {XK_F31, 'F', 'L'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
614 // {XK_F32, 'F', 'M'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
615 // {XK_F33, 'F', 'N'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
616 // {XK_F34, 'F', 'O'},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
617 // {XK_F35, 'F', 'P'}, // keysymdef.h defines up to F35
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
618
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
619 // {XK_Help, '%', '1'}, // XK_Help
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
620 {F(B_PRINT_KEY), '%', '9'},
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
621
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
622 #if 0
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
623 // Keypad keys:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
624 {F(0x48), 'k', 'l'}, // XK_KP_Left
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
625 {F(0x4A), 'k', 'r'}, // XK_KP_Right
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
626 {F(0x38), 'k', 'u'}, // XK_KP_Up
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
627 {F(0x59), 'k', 'd'}, // XK_KP_Down
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
628 {F(0x64), 'k', 'I'}, // XK_KP_Insert
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
629 {F(0x65), 'k', 'D'}, // XK_KP_Delete
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
630 {F(0x37), 'k', 'h'}, // XK_KP_Home
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
631 {F(0x58), '@', '7'}, // XK_KP_End
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
632 {F(0x39), 'k', 'P'}, // XK_KP_Prior
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
633 {F(0x60), 'k', 'N'}, // XK_KP_Next
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
634 {F(0x49), '&', '8'}, // XK_Undo, keypad 5
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
635 #endif
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
636
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
637 // End of list marker:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
638 {0, 0, 0}
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
639 };
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
640
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
641 #define NUM_SPECIAL_KEYS (sizeof(special_keys)/sizeof(special_keys[0]))
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
642
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
643 // ---------------- VimApp ----------------
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
644
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
645 static void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
646 docd(BPath &path)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
647 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
648 mch_chdir((char *)path.Path());
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
649 // Do this to get the side effects of a :cd command
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
650 do_cmdline_cmd((char_u *)"cd .");
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
651 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
652
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
653 static void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
654 drop_callback(void *cookie)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
655 {
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
656 // TODO here we could handle going to a specific position in the dropped
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
657 // file (see src/gui_mac.c)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
658 // Update the screen display
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
659 update_screen(NOT_VALID);
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
660 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
661
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
662 // Really handle dropped files and folders.
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
663 static void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
664 RefsReceived(BMessage *m, bool changedir)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
665 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
666 uint32 type;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
667 int32 count;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
668
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
669 m->PrintToStream();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
670 switch (m->what) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
671 case B_REFS_RECEIVED:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
672 case B_SIMPLE_DATA:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
673 m->GetInfo("refs", &type, &count);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
674 if (type != B_REF_TYPE)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
675 goto bad;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
676 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
677 case B_ARGV_RECEIVED:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
678 m->GetInfo("argv", &type, &count);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
679 if (type != B_STRING_TYPE)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
680 goto bad;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
681 if (changedir) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
682 char *dirname;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
683 if (m->FindString("cwd", (const char **) &dirname) == B_OK) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
684 chdir(dirname);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
685 do_cmdline_cmd((char_u *)"cd .");
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
686 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
687 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
688 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
689 default:
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
690 bad:
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
691 /*fprintf(stderr, "bad!\n"); */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
692 delete m;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
693 return;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
694 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
695
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
696 #ifdef FEAT_VISUAL
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
697 reset_VIsual();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
698 #endif
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
699
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
700 char_u **fnames;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
701 fnames = (char_u **) alloc(count * sizeof(char_u *));
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
702 int fname_index = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
703
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
704 switch (m->what) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
705 case B_REFS_RECEIVED:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
706 case B_SIMPLE_DATA:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
707 // fprintf(stderr, "case B_REFS_RECEIVED\n");
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
708 for (int i = 0; i < count; ++i)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
709 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
710 entry_ref ref;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
711 if (m->FindRef("refs", i, &ref) == B_OK) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
712 BEntry entry(&ref, false);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
713 BPath path;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
714 entry.GetPath(&path);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
715
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
716 // Change to parent directory?
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
717 if (changedir) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
718 BPath parentpath;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
719 path.GetParent(&parentpath);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
720 docd(parentpath);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
721 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
722
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
723 // Is it a directory? If so, cd into it.
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
724 BDirectory bdir(&ref);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
725 if (bdir.InitCheck() == B_OK) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
726 // don't cd if we already did it
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
727 if (!changedir)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
728 docd(path);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
729 } else {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
730 mch_dirname(IObuff, IOSIZE);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
731 char_u *fname = shorten_fname((char_u *)path.Path(), IObuff);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
732 if (fname == NULL)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
733 fname = (char_u *)path.Path();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
734 fnames[fname_index++] = vim_strsave(fname);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
735 // fprintf(stderr, "%s\n", fname);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
736 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
737
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
738 // Only do it for the first file/dir
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
739 changedir = false;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
740 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
741 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
742 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
743 case B_ARGV_RECEIVED:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
744 // fprintf(stderr, "case B_ARGV_RECEIVED\n");
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
745 for (int i = 1; i < count; ++i)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
746 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
747 char *fname;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
748
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
749 if (m->FindString("argv", i, (const char **) &fname) == B_OK) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
750 fnames[fname_index++] = vim_strsave((char_u *)fname);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
751 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
752 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
753 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
754 default:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
755 // fprintf(stderr, "case default\n");
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
756 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
757 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
758
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
759 delete m;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
760
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
761 // Handle the drop, :edit to get to the file
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
762 if (fname_index > 0) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
763 handle_drop(fname_index, fnames, FALSE, drop_callback, NULL);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
764
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
765 setcursor();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
766 out_flush();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
767 } else {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
768 vim_free(fnames);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
769 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
770 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
771
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
772 VimApp::VimApp(const char *appsig):
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
773 BApplication(appsig),
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
774 fFilePanelSem(-1),
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
775 fFilePanel(NULL)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
776 {
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
777 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
778
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
779 VimApp::~VimApp()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
780 {
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
781 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
782
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
783 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
784 VimApp::ReadyToRun()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
785 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
786 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
787 * Apparently signals are inherited by the created thread -
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
788 * disable the most annoying ones.
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
789 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
790 signal(SIGINT, SIG_IGN);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
791 signal(SIGQUIT, SIG_IGN);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
792 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
793
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
794 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
795 VimApp::ArgvReceived(int32 arg_argc, char **arg_argv)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
796 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
797 if (!IsLaunching()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
798 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
799 * This can happen if we are set to Single or Exclusive
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
800 * Launch. Be nice and open the file(s).
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
801 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
802 if (gui.vimWindow)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
803 gui.vimWindow->Minimize(false);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
804 BMessage *m = CurrentMessage();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
805 DetachCurrentMessage();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
806 SendRefs(m, true);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
807 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
808 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
809
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
810 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
811 VimApp::RefsReceived(BMessage *m)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
812 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
813 // Horrible hack!!! XXX XXX XXX
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
814 // The real problem is that b_start_ffc is set too late for
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
815 // the initial empty buffer. As a result the window will be
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
816 // split instead of abandoned.
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
817 int limit = 15;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
818 while (--limit >= 0 && (curbuf == NULL || curbuf->b_start_ffc == 0))
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
819 snooze(100000); // 0.1 s
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
820 if (gui.vimWindow)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
821 gui.vimWindow->Minimize(false);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
822 DetachCurrentMessage();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
823 SendRefs(m, true);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
824 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
825
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
826 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
827 * Pass a BMessage on to the main() thread.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
828 * Caller must have detached the message.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
829 */
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
830 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
831 VimApp::SendRefs(BMessage *m, bool changedir)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
832 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
833 VimRefsMsg rm;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
834 rm.message = m;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
835 rm.changedir = changedir;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
836
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
837 write_port(gui.vdcmp, VimMsg::Refs, &rm, sizeof(rm));
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
838 // calls ::RefsReceived
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
839 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
840
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
841 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
842 VimApp::MessageReceived(BMessage *m)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
843 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
844 switch (m->what) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
845 case 'save':
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
846 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
847 entry_ref refDirectory;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
848 m->FindRef("directory", &refDirectory);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
849 fBrowsedPath.SetTo(&refDirectory);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
850 BString strName;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
851 m->FindString("name", &strName);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
852 fBrowsedPath.Append(strName.String());
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
853 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
854 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
855 case 'open':
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
856 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
857 entry_ref ref;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
858 m->FindRef("refs", &ref);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
859 fBrowsedPath.SetTo(&ref);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
860 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
861 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
862 case B_CANCEL:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
863 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
864 BFilePanel *panel;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
865 m->FindPointer("source", (void**)&panel);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
866 if (fFilePanelSem != -1 && panel == fFilePanel)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
867 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
868 delete_sem(fFilePanelSem);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
869 fFilePanelSem = -1;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
870 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
871
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
872 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
873 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
874 default:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
875 Inherited::MessageReceived(m);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
876 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
877 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
878 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
879
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
880 bool
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
881 VimApp::QuitRequested()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
882 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
883 (void)Inherited::QuitRequested();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
884 return false;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
885 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
886
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
887 // ---------------- VimWindow ----------------
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
888
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
889 VimWindow::VimWindow():
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
890 BWindow(BRect(40, 40, 150, 150),
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
891 "Vim",
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
892 B_TITLED_WINDOW,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
893 0,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
894 B_CURRENT_WORKSPACE)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
895
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
896 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
897 init();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
898 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
899
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
900 VimWindow::~VimWindow()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
901 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
902 if (formView) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
903 RemoveChild(formView);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
904 delete formView;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
905 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
906 gui.vimWindow = NULL;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
907 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
908
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
909 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
910 VimWindow::init()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
911 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
912 // Attach the VimFormView
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
913 formView = new VimFormView(Bounds());
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
914 if (formView != NULL) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
915 AddChild(formView);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
916 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
917 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
918
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
919 #if 0 // disabled in zeta patch
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
920 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
921 VimWindow::DispatchMessage(BMessage *m, BHandler *h)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
922 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
923 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
924 * Route B_MOUSE_UP messages to MouseUp(), in
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
925 * a manner that should be compatible with the
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
926 * intended future system behaviour.
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
927 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
928 switch (m->what) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
929 case B_MOUSE_UP:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
930 // if (!h) h = PreferredHandler();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
931 // gcc isn't happy without this extra set of braces, complains about
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
932 // jump to case label crosses init of 'class BView * v'
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
933 // richard@whitequeen.com jul 99
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
934 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
935 BView *v = dynamic_cast<BView *>(h);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
936 if (v) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
937 // m->PrintToStream();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
938 BPoint where;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
939 m->FindPoint("where", &where);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
940 v->MouseUp(where);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
941 } else {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
942 Inherited::DispatchMessage(m, h);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
943 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
944 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
945 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
946 default:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
947 Inherited::DispatchMessage(m, h);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
948 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
949 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
950 #endif
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
951
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
952 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
953 VimWindow::WindowActivated(bool active)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
954 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
955 Inherited::WindowActivated(active);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
956 // the textArea gets the keyboard action
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
957 if (active && gui.vimTextArea)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
958 gui.vimTextArea->MakeFocus(true);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
959
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
960 struct VimFocusMsg fm;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
961 fm.active = active;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
962
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
963 write_port(gui.vdcmp, VimMsg::Focus, &fm, sizeof(fm));
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
964 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
965
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
966 bool
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
967 VimWindow::QuitRequested()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
968 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
969 struct VimKeyMsg km;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
970 km.length = 5;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
971 memcpy((char *)km.chars, "\033:qa\r", km.length);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
972 km.csi_escape = false;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
973 write_port(gui.vdcmp, VimMsg::Key, &km, sizeof(km));
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
974 return false;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
975 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
976
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
977 // ---------------- VimFormView ----------------
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
978
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
979 VimFormView::VimFormView(BRect frame):
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
980 BView(frame, "VimFormView", B_FOLLOW_ALL_SIDES,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
981 B_WILL_DRAW | B_FRAME_EVENTS),
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
982 menuBar(NULL),
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
983 #ifdef FEAT_TOOLBAR
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
984 toolBar(NULL),
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
985 #endif
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
986 #ifdef FEAT_GUI_TABLINE
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
987 // showingTabLine(false),
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
988 tabLine(NULL),
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
989 #endif
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
990 textArea(NULL)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
991 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
992 init(frame);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
993 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
994
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
995 VimFormView::~VimFormView()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
996 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
997 if (menuBar) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
998 RemoveChild(menuBar);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
999 #ifdef never
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1000 // deleting the menuBar leads to SEGV on exit
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1001 // richard@whitequeen.com Jul 99
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1002 delete menuBar;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1003 #endif
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1004 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1005
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1006 #ifdef FEAT_TOOLBAR
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1007 delete toolBar;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1008 #endif
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1009
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1010 #ifdef FEAT_GUI_TABLINE
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1011 delete tabLine;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1012 #endif
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1013
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1014 if (textArea) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1015 RemoveChild(textArea);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1016 delete textArea;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1017 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1018 gui.vimForm = NULL;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1019 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1020
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1021 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1022 VimFormView::init(BRect frame)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1023 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1024 menuBar = new BMenuBar(BRect(0,0,-MENUBAR_MARGIN,-MENUBAR_MARGIN),
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1025 "VimMenuBar");
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1026
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1027 AddChild(menuBar);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1028
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1029 #ifdef FEAT_TOOLBAR
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1030 toolBar = new VimToolbar(BRect(0,0,0,0), "VimToolBar");
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1031 toolBar->PrepareButtonBitmaps();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1032 AddChild(toolBar);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1033 #endif
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1034
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1035 #ifdef FEAT_GUI_TABLINE
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1036 tabLine = new VimTabLine(BRect(0,0,0,0));
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1037 // tabLine->PrepareButtonBitmaps();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1038 AddChild(tabLine);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1039 #endif
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1040
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1041 BRect remaining = frame;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1042 textArea = new VimTextAreaView(remaining);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1043 AddChild(textArea);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1044 // The textArea will be resized later when menus are added
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1045
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1046 gui.vimForm = this;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1047 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1048
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1049 #ifdef FEAT_TOOLBAR
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1050 float
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1051 VimFormView::ToolbarHeight() const
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1052 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1053 return toolBar ? toolBar->ToolbarHeight() : 0.;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1054 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1055 #endif
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1056
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1057 #ifdef FEAT_GUI_TABLINE
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1058 float
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1059 VimFormView::TablineHeight() const
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1060 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1061 return (tabLine && IsShowingTabLine()) ? tabLine->TablineHeight() : 0.;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1062 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1063 #endif
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1064
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1065 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1066 VimFormView::AllAttached()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1067 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1068 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1069 * Apparently signals are inherited by the created thread -
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1070 * disable the most annoying ones.
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1071 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1072 signal(SIGINT, SIG_IGN);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1073 signal(SIGQUIT, SIG_IGN);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1074
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1075 if (menuBar && textArea) {
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1076 /*
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1077 * Resize the textArea to fill the space left over by the menu.
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1078 * This is somewhat futile since it will be done again once
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1079 * menus are added to the menu bar.
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1080 */
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1081 BRect remaining = Bounds();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1082
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1083 #ifdef FEAT_MENU
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1084 remaining.top += MenuHeight();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1085 menuBar->ResizeTo(remaining.right, remaining.top);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1086 gui.menu_height = (int) MenuHeight();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1087 #endif
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1088
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1089 #ifdef FEAT_TOOLBAR
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1090 toolBar->MoveTo(remaining.left, remaining.top);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1091 toolBar->ResizeTo(remaining.right, ToolbarHeight());
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1092 remaining.top += ToolbarHeight();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1093 gui.toolbar_height = ToolbarHeight();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1094 #endif
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1095
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1096 #ifdef FEAT_GUI_TABLINE
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1097 tabLine->MoveTo(remaining.left, remaining.top);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1098 tabLine->ResizeTo(remaining.right + 1, TablineHeight());
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1099 remaining.top += TablineHeight();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1100 gui.tabline_height = TablineHeight();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1101 #endif
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1102
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1103 textArea->ResizeTo(remaining.Width(), remaining.Height());
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1104 textArea->MoveTo(remaining.left, remaining.top);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1105 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1106
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1107
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1108 Inherited::AllAttached();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1109 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1110
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1111 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1112 VimFormView::FrameResized(float new_width, float new_height)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1113 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1114 struct VimResizeMsg sm;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1115 int adjust_h, adjust_w;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1116
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1117 new_width += 1; // adjust from width to number of pixels occupied
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1118 new_height += 1;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1119
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1120 sm.width = (int) new_width;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1121 sm.height = (int) new_height;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1122 adjust_w = ((int)new_width - gui_get_base_width()) % gui.char_width;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1123 adjust_h = ((int)new_height - gui_get_base_height()) % gui.char_height;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1124
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1125 if (adjust_w > 0 || adjust_h > 0) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1126 sm.width -= adjust_w;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1127 sm.height -= adjust_h;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1128 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1129
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1130 write_port(gui.vdcmp, VimMsg::Resize, &sm, sizeof(sm));
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1131 // calls gui_resize_shell(new_width, new_height);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1132
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1133 return;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1134
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1135 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1136 * The area below the vertical scrollbar is erased to the colour
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1137 * set with SetViewColor() automatically, because we had set
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1138 * B_WILL_DRAW. Resizing the window tight around the vertical
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1139 * scroll bar also helps to avoid debris.
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1140 */
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1141 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1142
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1143 // ---------------- VimTextAreaView ----------------
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1144
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1145 VimTextAreaView::VimTextAreaView(BRect frame):
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1146 BView(frame, "VimTextAreaView", B_FOLLOW_ALL_SIDES,
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1147 #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
1148 B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_INPUT_METHOD_AWARE),
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1149 #else
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1150 B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1151 #endif
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1152 mouseDragEventCount(0)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1153 {
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1154 #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
1155 IMData.messenger = NULL;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1156 IMData.message = NULL;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1157 #endif
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1158 init(frame);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1159 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1160
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1161 VimTextAreaView::~VimTextAreaView()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1162 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1163 gui.vimTextArea = NULL;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1164 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1165
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1166 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1167 VimTextAreaView::init(BRect frame)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1168 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1169 // 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
1170 gui.vimTextArea = this;
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 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1173 * 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
1174 * 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
1175 * (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
1176 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1177 SetViewColor(B_TRANSPARENT_32_BIT);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1178 #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
1179 SetPenSize(PEN_WIDTH);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1180 #define W_WIDTH(curwin) 0
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1181 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1182
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1183 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1184 VimTextAreaView::Draw(BRect updateRect)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1185 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1186 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1187 * 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
1188 * 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
1189 * 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
1190 * 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
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 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1194 * 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
1195 * 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
1196 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1197 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
1198 SetLowColor(rgb);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1199 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
1200 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
1201 (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
1202
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1203 // 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
1204 SetLowColor(rgb);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1205
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1206 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
1207 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
1208 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
1209 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
1210 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
1211 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
1212 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
1213 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
1214 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
1215 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
1216 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
1217 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
1218
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1219 #ifdef FEAT_MBYTE_IME
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1220 DrawIMString();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1221 #endif
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1224 void
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1225 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
1226 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1227 struct VimKeyMsg km;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1228 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
1229
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1230 bool canHaveVimModifiers = false;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1231
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1232 BMessage *msg = Window()->CurrentMessage();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1233 assert(msg);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1234 // msg->PrintToStream();
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 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1237 * 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
1238 * 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
1239 * 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
1240 * 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
1241 * 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
1242 * do...
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1243 * 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
1244 * 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
1245 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1246 if (numBytes > 1) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1247 // 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
1248 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
1249 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
1250 km.length = numBytes;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1251 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
1252 km.csi_escape = true;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1253 } else {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1254 int32 scancode = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1255 msg->FindInt32("key", &scancode);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1256
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1257 int32 beModifiers = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1258 msg->FindInt32("modifiers", &beModifiers);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1259
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1260 char_u string[3];
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1261 int len = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1262 km.length = 0;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1263
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1264 /*
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1265 * 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
1266 * to check if they might be a special key. They aren't.
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1267 */
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1268 assert(B_BACKSPACE <= 0x20);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1269 assert(B_DELETE == 0x7F);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1270 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
1271 numBytes == 1) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1272 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1273 * 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
1274 * 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
1275 * 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
1276 * 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
1277 * 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
1278 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1279 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
1280 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
1281 int newNumBytes = keyMapChars[index];
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1282 char_u *newBytes = (char_u *)&keyMapChars[index + 1];
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1283
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1284 /*
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1285 * 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
1286 * 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
1287 * 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
1288 * Otherwise we could simply have checked for equality.
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1289 */
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1290 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
1291 *newBytes != 0x7F )) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1292 goto notspecial;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1293 }
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1294 bytes = (char *)newBytes;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1295 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1296 canHaveVimModifiers = true;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1297
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1298 uint16 beoskey;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1299 int first, last;
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 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1302 * 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
1303 * (does not happen yet)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1304 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1305 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
1306 beoskey = F(scancode);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1307 first = FIRST_FUNCTION_KEY;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1308 last = NUM_SPECIAL_KEYS;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1309 } 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
1310 // 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
1311 string[0] = '\r';
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1312 len = 1;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1313 first = last = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1314 } else {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1315 beoskey = K(bytes[0]);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1316 first = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1317 last = FIRST_FUNCTION_KEY;
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1320 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
1321 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
1322 string[0] = CSI;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1323 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
1324 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
1325 len = 3;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1326 }
20152
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 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1329 notspecial:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1330 if (len == 0) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1331 string[0] = bytes[0];
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1332 len = 1;
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1335 // Special keys (and a few others) may have modifiers
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1336 #if 0
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1337 if (len == 3 ||
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1338 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
1339 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
1340 bytes[0] == B_ESCAPE)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1341 #else
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1342 if (canHaveVimModifiers)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1343 #endif
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1344 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1345 int modifiers;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1346 modifiers = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1347 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
1348 modifiers |= MOD_MASK_SHIFT;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1349 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
1350 modifiers |= MOD_MASK_CTRL;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1351 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
1352 modifiers |= MOD_MASK_ALT;
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 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1355 * 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
1356 * 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
1357 * 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
1358 * string[0] == CSI...)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1359 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1360 int key;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1361 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
1362 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
1363 else
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1364 key = string[0];
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1365 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
1366 if (IS_SPECIAL(key))
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1367 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1368 string[0] = CSI;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1369 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
1370 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
1371 len = 3;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1372 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1373 else
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1374 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1375 string[0] = key;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1376 len = 1;
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1379 if (modifiers)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1380 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1381 *dest++ = CSI;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1382 *dest++ = KS_MODIFIER;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1383 *dest++ = modifiers;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1384 km.length = 3;
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 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1387 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
1388 km.length += len;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1389 km.csi_escape = false;
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1392 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
1393
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1394 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1395 * 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
1396 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1397 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
1398 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1399 guiBlankMouse(true);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1400 gui.pointer_hidden = TRUE;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1401 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1402 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1403 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1404 VimTextAreaView::guiSendMouseEvent(
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1405 int button,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1406 int x,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1407 int y,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1408 int repeated_click,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1409 int_u modifiers)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1410 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1411 VimMouseMsg mm;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1412
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1413 mm.button = button;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1414 mm.x = x;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1415 mm.y = y;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1416 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
1417 mm.modifiers = modifiers;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1418
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1419 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
1420 // 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
1421
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1422 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1423 * 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
1424 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1425 if (gui.pointer_hidden)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1426 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1427 guiBlankMouse(false);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1428 gui.pointer_hidden = FALSE;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1429 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1430 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1431
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1432 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1433 VimTextAreaView::guiMouseMoved(
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1434 int x,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1435 int y)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1436 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1437 VimMouseMovedMsg mm;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1438
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1439 mm.x = x;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1440 mm.y = y;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1441
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1442 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
1443
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1444 if (gui.pointer_hidden)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1445 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1446 guiBlankMouse(false);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1447 gui.pointer_hidden = FALSE;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1448 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1449 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1450
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1451 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1452 VimTextAreaView::guiBlankMouse(bool should_hide)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1453 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1454 if (should_hide) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1455 // gui.vimApp->HideCursor();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1456 gui.vimApp->ObscureCursor();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1457 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1458 * 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
1459 * 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
1460 * correspond to reality.
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1461 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1462 } else {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1463 // gui.vimApp->ShowCursor();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1464 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1465 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1466
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1467 int_u
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1468 VimTextAreaView::mouseModifiersToVim(int32 beModifiers)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1469 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1470 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
1471
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1472 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
1473 vim_modifiers |= MOUSE_SHIFT;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1474 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
1475 vim_modifiers |= MOUSE_CTRL;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1476 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
1477 vim_modifiers |= MOUSE_ALT;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1478
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1479 return vim_modifiers;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1480 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1481
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1482 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1483 VimTextAreaView::MouseDown(BPoint point)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1484 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1485 BMessage *m = Window()->CurrentMessage();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1486 assert(m);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1487
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1488 int32 buttons = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1489 m->FindInt32("buttons", &buttons);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1490
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1491 int vimButton;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1492
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1493 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
1494 vimButton = MOUSE_LEFT;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1495 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
1496 vimButton = MOUSE_RIGHT;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1497 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
1498 vimButton = MOUSE_MIDDLE;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1499 else
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1500 return; // Unknown button
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1501
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1502 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
1503
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1504 // Handle multiple clicks
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1505 int32 clicks = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1506 m->FindInt32("clicks", &clicks);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1507
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1508 int32 modifiers = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1509 m->FindInt32("modifiers", &modifiers);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1510
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1511 vimMouseModifiers = mouseModifiersToVim(modifiers);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1512
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1513 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
1514 clicks > 1 /* = repeated_click*/, vimMouseModifiers);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1515 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1516
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1517 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1518 VimTextAreaView::MouseUp(BPoint point)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1519 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1520 vimMouseButton = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1521
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1522 BMessage *m = Window()->CurrentMessage();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1523 assert(m);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1524 // m->PrintToStream();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1525
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1526 int32 modifiers = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1527 m->FindInt32("modifiers", &modifiers);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1528
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1529 vimMouseModifiers = mouseModifiersToVim(modifiers);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1530
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1531 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
1532 0 /* = repeated_click*/, vimMouseModifiers);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1533
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1534 Inherited::MouseUp(point);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1535 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1536
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1537 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1538 VimTextAreaView::MouseMoved(BPoint point, uint32 transit, const BMessage *message)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1539 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1540 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1541 * 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
1542 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1543 if (gui.pointer_hidden)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1544 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1545 guiBlankMouse(false);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1546 gui.pointer_hidden = FALSE;
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1549 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
1550 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
1551 return;
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1554 atomic_add(&mouseDragEventCount, 1);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1555
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1556 // 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
1557 guiSendMouseEvent(MOUSE_DRAG, point.x, point.y, 0, vimMouseModifiers);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1558 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1559
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1560 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1561 VimTextAreaView::MessageReceived(BMessage *m)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1562 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1563 switch (m->what) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1564 case 'menu':
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1565 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1566 VimMenuMsg mm;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1567 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
1568 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
1569 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
1570 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1571 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1572 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
1573 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1574 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
1575 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
1576 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
1577 scb->GetSteps(&small, &big);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1578 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
1579 scb->ValueChanged(scb->Value());
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1580 #if 0
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1581 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
1582 scb->GetSteps(&small, &big);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1583 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
1584 scb->ValueChanged(scb->Value());
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1585 #endif
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1586 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1587 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1588 #ifdef FEAT_MBYTE_IME
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1589 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
1590 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1591 int32 opcode;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1592 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
1593 switch(opcode)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1594 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1595 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
1596 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
1597 IMData.messenger = new BMessenger();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1598 m->FindMessenger("be:reply_to", IMData.messenger);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1599 break;
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1600 case B_INPUT_METHOD_CHANGED:
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1601 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1602 BString str;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1603 bool confirmed;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1604 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
1605 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
1606 DrawIMString();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1607 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
1608 if (confirmed)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1609 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1610 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
1611 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
1612 struct VimKeyMsg km;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1613 km.csi_escape = true;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1614 int clen;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1615 int i = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1616 while (i < str.Length())
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1617 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1618 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
1619 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
1620 km.length = clen;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1621 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
1622 i += clen;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1623 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1624 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1625 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1626 break;
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1627 case B_INPUT_METHOD_LOCATION_REQUEST:
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1628 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1629 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
1630 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
1631 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
1632 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
1633 IMData.messenger->SendMessage(&msg);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1634 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1635 break;
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1636 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
1637 delete IMData.messenger;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1638 delete IMData.message;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1639 IMData.messenger = NULL;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1640 IMData.message = NULL;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1641 break;
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 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1644 // TODO: sz: break here???
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1645 #endif
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1646 default:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1647 if (m->WasDropped()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1648 BWindow *w = Window();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1649 w->DetachCurrentMessage();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1650 w->Minimize(false);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1651 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
1652 } else {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1653 Inherited::MessageReceived(m);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1654 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1655 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1656 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1657 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1658
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1659 int
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1660 VimTextAreaView::mchInitFont(char_u *name)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1661 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1662 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
1663 if (newFont != NOFONT) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1664 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
1665 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
1666 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
1667 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
1668
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1669 SetDrawingMode(B_OP_COPY);
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 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1672 * 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
1673 * 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
1674 * 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
1675 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1676 return OK;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1677 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1678 return FAIL;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1679 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1680
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1681 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1682 VimTextAreaView::mchDrawString(int row, int col, char_u *s, int len, int flags)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1683 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1684 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1685 * 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
1686 * 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
1687 * 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
1688 * 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
1689 * (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
1690 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1691 if (!(flags & DRAW_TRANSP)) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1692 int cells;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1693 cells = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1694 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
1695 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
1696 if (cn<4) cells += cn;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1697 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1698
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1699 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
1700 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
1701 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
1702 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1703
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1704 BFont font;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1705 this->GetFont(&font);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1706 if (!font.IsFixed())
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1707 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1708 char* p = (char*)s;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1709 int32 clen, lastpos = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1710 BPoint where;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1711 int cells;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1712 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
1713 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
1714 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
1715 DrawString(p, clen, where);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1716 if (flags & DRAW_BOLD) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1717 where.x += 1.0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1718 SetDrawingMode(B_OP_BLEND);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1719 DrawString(p, clen, where);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1720 SetDrawingMode(B_OP_COPY);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1721 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1722 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
1723 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
1724 else lastpos++;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1725 p += clen;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1726 }
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1727 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1728 else
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1729 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1730 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
1731 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
1732 if (flags & DRAW_BOLD) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1733 where.x += 1.0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1734 SetDrawingMode(B_OP_BLEND);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1735 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
1736 SetDrawingMode(B_OP_COPY);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1737 }
20152
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1740 if (flags & DRAW_UNDERL) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1741 int cells;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1742 cells = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1743 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
1744 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
1745 if (cn<4) cells += cn;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1746 }
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1747
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1748 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
1749 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
1750
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1751 StrokeLine(start, end);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1752 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1753 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1754
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1755 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1756 VimTextAreaView::mchClearBlock(
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1757 int row1,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1758 int col1,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1759 int row2,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1760 int col2)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1761 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1762 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
1763 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
1764 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
1765 FillRect(r, B_SOLID_LOW);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1766 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1767
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1768 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1769 VimTextAreaView::mchClearAll()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1770 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1771 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
1772 FillRect(Bounds(), B_SOLID_LOW);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1773 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1774
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1775 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1776 * mchDeleteLines() Lock()s the window by itself.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1777 */
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1778 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1779 VimTextAreaView::mchDeleteLines(int row, int num_lines)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1780 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1781 BRect source, dest;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1782 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
1783 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
1784 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
1785 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
1786
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1787 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
1788 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
1789 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
1790 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
1791
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1792 if (gui.vimWindow->Lock()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1793 // 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
1794 CopyBits(source, dest);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1795 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
1796 gui.scroll_region_left,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1797 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
1798
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1799
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1800 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1801 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1802 * 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
1803 * 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
1804 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1805 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1806 // 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
1807 // }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1808 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1809
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1810 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1811 * mchInsertLines() Lock()s the window by itself.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1812 */
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1813 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1814 VimTextAreaView::mchInsertLines(int row, int num_lines)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1815 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1816 BRect source, dest;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1817
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1818 // 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
1819 gui.vimWindow->UpdateIfNeeded();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1820 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
1821 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
1822 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
1823 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
1824
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1825 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
1826 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
1827 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
1828 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
1829
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1830 if (gui.vimWindow->Lock()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1831 // 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
1832 CopyBits(source, dest);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1833 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
1834 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
1835
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1836 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1837 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1838 * 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
1839 * 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
1840 * 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
1841 * 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
1842 * 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
1843 * 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
1844 * 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
1845 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1846
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1847 // 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
1848
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1849 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1850 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1851
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1852 #ifdef FEAT_MBYTE_IME
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1853 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1854 * DrawIMString draws string with IMData.message.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1855 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1856 void VimTextAreaView::DrawIMString(void)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1857 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1858 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
1859 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
1860 BString str;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1861 const char* s;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1862 int len;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1863 BMessage* msg = IMData.message;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1864 if (!msg)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1865 return;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1866 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
1867 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
1868 bool confirmed = false;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1869 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
1870 if (confirmed)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1871 return;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1872 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
1873 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
1874 s = str.String();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1875 len = str.Length();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1876 SetHighColor(0, 0, 0);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1877 IMData.row = gui.row;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1878 IMData.col = gui.col;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1879 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
1880 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
1881 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
1882 int clen, cn;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1883 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
1884 BRect r;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1885 BPoint where;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1886 IMData.location = ConvertToScreen(
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1887 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
1888 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
1889 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1890 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
1891 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
1892 if (pos.x + cn > W_WIDTH(curwin))
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1893 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1894 pos.y++;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1895 pos.x = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1896 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1897 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
1898 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1899 SetLowColor(r_highlight);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1900 IMData.location = ConvertToScreen(
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1901 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
1902 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1903 else
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1904 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1905 SetLowColor(b_highlight);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1906 }
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1907 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
1908 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
1909 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
1910 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
1911 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
1912 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
1913 pos.x += cn;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1914 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1915 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
1916
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1917 SetHighColor(hcolor);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1918 SetLowColor(lcolor);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1919 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1920 #endif
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1921 // ---------------- VimScrollBar ----------------
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1922
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1923 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1924 * BUG: XXX
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1925 * It seems that BScrollBar determine their direction not from
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1926 * "posture" but from if they are "tall" or "wide" in shape...
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1927 *
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1928 * Also, place them out of sight, because Vim enables them before
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1929 * they are positioned.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1930 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1931 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
1932 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
1933 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
1934 "vim scrollbar", (BView *)NULL,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1935 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
1936 ignoreValue(-1),
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1937 scrollEventCount(0)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1938 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1939 gsb = g;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1940 SetResizingMode(B_FOLLOW_NONE);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1941 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1942
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1943 VimScrollBar::~VimScrollBar()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1944 {
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1945 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1946
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1947 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1948 VimScrollBar::ValueChanged(float newValue)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1949 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1950 if (ignoreValue >= 0.0 && newValue == ignoreValue) {
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1951 ignoreValue = -1;
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1952 return;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1953 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1954 ignoreValue = -1;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1955 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1956 * 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
1957 * 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
1958 * 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
1959 * 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
1960 * 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
1961 * 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
1962 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1963 atomic_add(&scrollEventCount, 1);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1964
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1965 struct VimScrollBarMsg sm;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1966
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1967 sm.sb = this;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1968 sm.value = (long) newValue;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1969 sm.stillDragging = TRUE;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1970
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1971 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
1972
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1973 // calls gui_drag_scrollbar(sb, newValue, TRUE);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1974 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1975
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1976 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1977 * When the mouse goes up, report that scrolling has stopped.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1978 * MouseUp() is NOT called when the mouse-up occurs outside
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1979 * the window, even though the thumb does move while the mouse
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1980 * is outside... This has some funny effects... XXX
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1981 * So we do special processing when the window de/activates.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1982 */
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1983 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1984 VimScrollBar::MouseUp(BPoint where)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1985 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1986 // BMessage *m = Window()->CurrentMessage();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1987 // m->PrintToStream();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1988
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1989 atomic_add(&scrollEventCount, 1);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1990
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1991 struct VimScrollBarMsg sm;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1992
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1993 sm.sb = this;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1994 sm.value = (long) Value();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1995 sm.stillDragging = FALSE;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1996
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1997 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
1998
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
1999 // 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
2000
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2001 Inherited::MouseUp(where);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2002 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2003
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2004 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2005 VimScrollBar::SetValue(float newValue)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2006 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2007 if (newValue == Value())
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2008 return;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2009
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2010 ignoreValue = newValue;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2011 Inherited::SetValue(newValue);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2012 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2013
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2014 // ---------------- VimFont ----------------
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2015
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2016 VimFont::VimFont(): BFont()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2017 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2018 init();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2019 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2020
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2021 VimFont::VimFont(const VimFont *rhs): BFont(rhs)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2022 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2023 init();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2024 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2025
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2026 VimFont::VimFont(const BFont *rhs): BFont(rhs)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2027 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2028 init();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2029 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2030
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2031 VimFont::VimFont(const VimFont &rhs): BFont(rhs)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2032 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2033 init();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2034 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2035
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2036 VimFont::~VimFont()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2037 {
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2038 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2039
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2040 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2041 VimFont::init()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2042 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2043 next = NULL;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2044 refcount = 1;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2045 name = NULL;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2046 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2047
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2048 // ---------------- VimDialog ----------------
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2049
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2050 #if defined(FEAT_GUI_DIALOG)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2051
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2052 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
2053 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
2054 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
2055 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
2056 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
2057 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
2058 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
2059 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
2060 const BRect kDefaultRect =
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2061 BRect(0, 0, kVimDialogMinimalWidth, kVimDialogMinimalHeight);
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2062
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2063 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
2064 const char *buttons, int dfltbutton, const char *textfield, int ex_cmd)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2065 : 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
2066 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
2067 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
2068 , fDialogSem(-1)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2069 , fDialogValue(dfltbutton)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2070 , fMessageView(NULL)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2071 , fInputControl(NULL)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2072 , fInputValue(textfield)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2073 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2074 // master view
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2075 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
2076 if (view == NULL)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2077 return;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2078
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2079 if (title == NULL)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2080 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
2081
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2082 AddChild(view);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2083
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2084 // icon
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2085 view->InitIcon(type);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2086
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2087 // buttons
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2088 int32 which = 1;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2089 float maxButtonWidth = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2090 float maxButtonHeight = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2091 float buttonsWidth = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2092 float buttonsHeight = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2093 BString strButtons(buttons);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2094 strButtons.RemoveAll("&");
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2095 do {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2096 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
2097 if (end != B_ERROR)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2098 strButtons.SetByteAt(end, '\0');
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2099
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2100 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
2101 view->AddChild(button);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2102 fButtonsList.AddItem(button);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2103
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2104 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
2105 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
2106 buttonsWidth += button->Bounds().Width();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2107 buttonsHeight += button->Bounds().Height();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2108
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2109 if (end == B_ERROR)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2110 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2111
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2112 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
2113 } while (true);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2114
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2115 int32 buttonsCount = fButtonsList.CountItems();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2116 buttonsWidth += kVimDialogButtonsSpacingX * (buttonsCount - 1);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2117 buttonsHeight += kVimDialogButtonsSpacingY * (buttonsCount - 1);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2118 float dialogWidth = buttonsWidth + kVimDialogIconStripeWidth +
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2119 kVimDialogSpacingX * 2;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2120 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
2121
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2122 // 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
2123 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
2124 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
2125 if (vertical) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2126 dialogWidth -= buttonsWidth;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2127 dialogWidth += maxButtonWidth;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2128 dialogHeight -= maxButtonHeight;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2129 dialogHeight += buttonsHeight;
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2132 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
2133
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2134 // message view
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2135 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
2136 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
2137 rect.top += kVimDialogSpacingY;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2138 rect.right -= kVimDialogSpacingX;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2139 rect.bottom = rect.top;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2140 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
2141 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
2142
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2143 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
2144 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
2145 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
2146 fMessageView->SetText(message);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2147 fMessageView->MakeEditable(false);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2148 fMessageView->MakeSelectable(false);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2149 fMessageView->SetWordWrap(true);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2150 AddChild(fMessageView);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2151
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2152 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
2153 fMessageView->ResizeBy(0, messageHeight);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2154 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
2155
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2156 dialogHeight += messageHeight;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2157
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2158 // input view
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2159 if (fInputValue != NULL) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2160 rect.top =
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2161 rect.bottom += messageHeight + kVimDialogSpacingY;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2162 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
2163 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
2164 fInputControl->TextView()->SetText(fInputValue);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2165 fInputControl->TextView()->SetWordWrap(false);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2166 AddChild(fInputControl);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2167
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2168 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
2169 fInputControl->GetPreferredSize(&width, &height);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2170 fInputControl->MakeFocus(true);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2171
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2172 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
2173 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2174
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2175 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
2176
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2177 ResizeTo(dialogWidth, dialogHeight);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2178 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
2179 (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
2180
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2181 // adjust layout of buttons
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2182 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
2183 BPoint origin(dialogWidth, dialogHeight);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2184 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
2185 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
2186
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2187 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
2188 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
2189 button->MoveTo(origin);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2190 if (vertical) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2191 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
2192 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
2193 } else
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2194 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
2195
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2196 if (dfltbutton == i + 1) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2197 button->MakeDefault(true);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2198 button->MakeFocus(fInputControl == NULL);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2199 }
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2200 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2201 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2202
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2203 VimDialog::~VimDialog()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2204 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2205 if (fDialogSem > B_OK)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2206 delete_sem(fDialogSem);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2207 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2208
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2209 int
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2210 VimDialog::Go()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2211 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2212 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
2213 if (fDialogSem < B_OK) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2214 Quit();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2215 return fDialogValue;
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2218 Show();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2219
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2220 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
2221
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2222 int retValue = fDialogValue;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2223 if (fInputValue != NULL)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2224 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
2225
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2226 if (Lock())
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2227 Quit();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2228
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2229 return retValue;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2230 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2231
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2232 void VimDialog::MessageReceived(BMessage *msg)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2233 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2234 int32 which = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2235 if (msg->what != kVimDialogButtonMsg ||
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2236 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
2237 return BWindow::MessageReceived(msg);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2238
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2239 fDialogValue = which;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2240 delete_sem(fDialogSem);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2241 fDialogSem = -1;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2242 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2243
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2244 BButton* VimDialog::_CreateButton(int32 which, const char* label)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2245 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2246 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
2247 message->AddInt32("which", which);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2248
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2249 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
2250 BString name;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2251 name << "_b" << which << "_";
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2252
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2253 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
2254 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
2255
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2256 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
2257 button->GetPreferredSize(&width, &height);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2258 button->ResizeTo(width, height);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2259
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2260 return button;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2261 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2262
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2263 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
2264 : 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
2265 fIconBitmap(NULL)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2266 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2267 SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2268 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2269
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2270 VimDialog::View::~View()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2271 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2272 delete fIconBitmap;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2273 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2274
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2275 void VimDialog::View::Draw(BRect updateRect)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2276 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2277 BRect stripeRect = Bounds();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2278 stripeRect.right = kVimDialogIconStripeWidth;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2279 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
2280 FillRect(stripeRect);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2281
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2282 if (fIconBitmap == NULL)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2283 return;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2284
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2285 SetDrawingMode(B_OP_ALPHA);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2286 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
2287 DrawBitmapAsync(fIconBitmap, BPoint(18, 6));
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2288 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2289
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2290 void VimDialog::View::InitIcon(int32 type)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2291 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2292 if (type == VIM_GENERIC)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2293 return;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2294
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2295 BPath path;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2296 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
2297 if (status != B_OK) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2298 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
2299 return;
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2302 path.Append("app_server");
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2303
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2304 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
2305 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
2306 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
2307 strerror(file.InitCheck()));
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2308 return;
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2311 BResources resources(&file);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2312 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
2313 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
2314 strerror(resources.InitCheck()));
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2315 return;
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2318 const char *name = "";
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2319 switch(type) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2320 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
2321 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
2322 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
2323 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
2324 default: return;
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2327 int32 iconSize = 32;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2328 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
2329 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
2330 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
2331 (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
2332 return;
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2335 size_t size = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2336 const uint8* iconData = NULL;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2337 // try vector icon first?
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2338 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
2339 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
2340 return;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2341
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2342 // try bitmap icon now
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2343 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
2344 if (iconData == NULL) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2345 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
2346 delete fIconBitmap;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2347 fIconBitmap = NULL;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2348 return;
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2351 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
2352 BIconUtils::ConvertFromCMAP8(iconData, iconSize, iconSize, iconSize, fIconBitmap);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2353 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2354
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2355 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
2356 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
2357 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
2358 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
2359 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
2360 const unsigned int kVimDialogSizeSelectMsg = 'MSSZ';
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2361
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2362 VimSelectFontDialog::VimSelectFontDialog(font_family* family, font_style* style, float* size)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2363 : 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
2364 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
2365 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
2366 , fStatus(B_NO_INIT)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2367 , fDialogSem(-1)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2368 , fDialogValue(false)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2369 , fFamily(family)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2370 , fStyle(style)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2371 , fSize(size)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2372 , fFontSize(*size)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2373 , fPreview(0)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2374 , fFamiliesList(0)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2375 , fStylesList(0)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2376 , fSizesList(0)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2377 , fSizesInput(0)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2378 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2379 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
2380 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
2381
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2382 // "client" area view
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2383 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
2384 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
2385 B_PLAIN_BORDER);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2386 AddChild(clientBox);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2387
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2388 // client view
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2389 BRect RC = clientBox->Bounds();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2390 RC.InsetBy(kVimDialogSpacingX, kVimDialogSpacingY);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2391 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
2392
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2393 // 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
2394 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
2395 clientBox->AddChild(fPreview);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2396
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2397 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
2398 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
2399 clientBox->AddChild(boxDivider);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2400
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2401 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
2402 clientBox->AddChild(labelFamily);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2403 labelFamily->ResizeToPreferred();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2404
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2405 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
2406 clientBox->AddChild(labelStyle);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2407 labelStyle->ResizeToPreferred();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2408
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2409 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
2410 clientBox->AddChild(labelSize);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2411 labelSize->ResizeToPreferred();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2412
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2413 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
2414 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
2415 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
2416 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
2417 clientBox->AddChild(scrollFamilies);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2418
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2419 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
2420 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
2421 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
2422 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
2423 clientBox->AddChild(scrollStyles);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2424
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2425 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
2426 new BMessage(kVimDialogSizeInputMsg));
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2427 clientBox->AddChild(fSizesInput);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2428 fSizesInput->ResizeToPreferred();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2429
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2430 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
2431 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
2432 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
2433 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
2434 clientBox->AddChild(scrollSizes);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2435
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2436 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
2437 new BMessage(kVimDialogOKButtonMsg));
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2438 clientBox->AddChild(buttonOK);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2439 buttonOK->ResizeToPreferred();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2440
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2441 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
2442 new BMessage(kVimDialogCancelButtonMsg));
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2443 clientBox->AddChild(buttonCancel);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2444 buttonCancel->ResizeToPreferred();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2445
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2446 // layout controls
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2447 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
2448 float previewHeight = lineHeight * 3;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2449 float offsetYLabels = previewHeight + kVimDialogSpacingY;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2450 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
2451 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
2452 float listsHeight = lineHeight * 9;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2453 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
2454 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
2455 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
2456 float offsetXStyles = familiesWidth + kVimDialogSpacingX;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2457 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
2458 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
2459 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
2460 float maxControlsWidth = offsetXSizes + sizesWidth;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2461
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2462 ResizeTo(maxControlsWidth + kVimDialogSpacingX * 2,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2463 maxControlsHeight + kVimDialogSpacingY * 2);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2464
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2465 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
2466 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
2467 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
2468
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2469 fPreview->ResizeTo(maxControlsWidth, previewHeight);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2470 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
2471
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2472 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
2473 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
2474
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2475 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
2476 labelStyle->MoveBy(offsetXStyles, offsetYLabels);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2477 labelSize->MoveBy(offsetXSizes, offsetYLabels);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2478
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2479 // text control alignment issues
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2480 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
2481 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
2482
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2483 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
2484 scrollStyles->MoveBy(offsetXStyles, offsetYLists);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2485 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
2486 scrollSizes->MoveBy(offsetXSizes, offsetYSizes);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2487
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2488 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
2489
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2490 scrollFamilies->ResizeTo(familiesWidth, listsHeight);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2491 scrollStyles->ResizeTo(stylesWidth, listsHeight);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2492 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
2493 scrollSizes->ResizeTo(sizesWidth,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2494 listsHeight - (offsetYSizes - offsetYLists));
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2495
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2496 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
2497 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
2498 - 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
2499
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2500 // fill lists
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2501 int selIndex = -1;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2502 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
2503 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
2504 font_family family;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2505 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
2506 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
2507 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
2508 selIndex = i;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2509 }
20152
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2512 if (selIndex >= 0) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2513 fFamiliesList->Select(selIndex);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2514 fFamiliesList->ScrollToSelection();
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2517 _UpdateFontStyles();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2518
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2519 selIndex = -1;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2520 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
2521 BString str;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2522 str << size;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2523 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
2524 if (size == fFontSize)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2525 selIndex = index;
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2529 if (selIndex >= 0) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2530 fSizesList->Select(selIndex);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2531 fSizesList->ScrollToSelection();
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2534 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
2535 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
2536 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
2537 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
2538
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2539 _UpdateSizeInputPreview();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2540 _UpdateFontPreview();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2541
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2542 fStatus = B_OK;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2543 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2544
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2545 VimSelectFontDialog::~VimSelectFontDialog()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2546 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2547 _CleanList(fFamiliesList);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2548 _CleanList(fStylesList);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2549 _CleanList(fSizesList);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2550
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2551 if (fDialogSem > B_OK)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2552 delete_sem(fDialogSem);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2553 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2554
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2555 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2556 VimSelectFontDialog::_CleanList(BListView* list)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2557 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2558 while (0 < list->CountItems())
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2559 delete (dynamic_cast<BStringItem*>(list->RemoveItem((int32)0)));
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2560 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2561
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2562 bool
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2563 VimSelectFontDialog::Go()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2564 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2565 if (fStatus != B_OK) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2566 Quit();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2567 return NOFONT;
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2570 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
2571 if (fDialogSem < B_OK) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2572 Quit();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2573 return fDialogValue;
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2576 Show();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2577
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2578 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
2579
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2580 bool retValue = fDialogValue;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2581
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2582 if (Lock())
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2583 Quit();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2584
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2585 return retValue;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2586 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2587
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2588
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2589 void VimSelectFontDialog::_UpdateFontStyles()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2590 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2591 _CleanList(fStylesList);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2592
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2593 int32 selIndex = -1;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2594 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
2595 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
2596 font_style style;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2597 uint32 flags = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2598 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
2599 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
2600 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
2601 selIndex = i;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2602 }
20152
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2605 if (selIndex >= 0) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2606 fStylesList->Select(selIndex);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2607 fStylesList->ScrollToSelection();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2608 } else
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2609 fStylesList->Select(0);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2610 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2611
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2612
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2613 void VimSelectFontDialog::_UpdateSizeInputPreview()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2614 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2615 char buf[10] = {0};
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2616 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
2617 fSizesInput->SetText(buf);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2618 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2619
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2620
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2621 void VimSelectFontDialog::_UpdateFontPreview()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2622 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2623 BFont font;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2624 fPreview->GetFont(&font);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2625 font.SetSize(fFontSize);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2626 font.SetFamilyAndStyle(fFontFamily, fFontStyle);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2627 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
2628
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2629 BString str;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2630 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
2631 fPreview->SetText(str);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2632 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2633
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2634
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2635 bool
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2636 VimSelectFontDialog::_UpdateFromListItem(BListView* list, char* text, int textSize)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2637 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2638 int32 index = list->CurrentSelection();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2639 if (index < 0)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2640 return false;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2641 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
2642 if (item == NULL)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2643 return false;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2644 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
2645 return true;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2646 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2647
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2648
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2649 void VimSelectFontDialog::MessageReceived(BMessage *msg)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2650 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2651 switch (msg->what) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2652 case kVimDialogOKButtonMsg:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2653 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
2654 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
2655 *fSize = fFontSize;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2656 fDialogValue = true;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2657 case kVimDialogCancelButtonMsg:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2658 delete_sem(fDialogSem);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2659 fDialogSem = -1;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2660 return;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2661 case B_KEY_UP:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2662 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2663 int32 key = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2664 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
2665 && key == B_ESCAPE) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2666 delete_sem(fDialogSem);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2667 fDialogSem = -1;
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 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2670 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2671
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2672 case kVimDialogFamilySelectMsg:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2673 if (_UpdateFromListItem(fFamiliesList,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2674 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
2675 _UpdateFontStyles();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2676 _UpdateFontPreview();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2677 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2678 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2679 case kVimDialogStyleSelectMsg:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2680 if (_UpdateFromListItem(fStylesList,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2681 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
2682 _UpdateFontPreview();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2683 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2684 case kVimDialogSizeSelectMsg:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2685 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2686 char buf[10] = {0};
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2687 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
2688 float size = atof(buf);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2689 if (size > 0.f) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2690 fFontSize = size;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2691 _UpdateSizeInputPreview();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2692 _UpdateFontPreview();
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 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2696 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2697 case kVimDialogSizeInputMsg:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2698 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2699 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
2700 if (size > 0.f) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2701 fFontSize = size;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2702 _UpdateFontPreview();
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 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2705 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2706 default:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2707 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2708 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2709 return BWindow::MessageReceived(msg);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2710 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2711
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2712 #endif // FEAT_GUI_DIALOG
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2713
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2714 #ifdef FEAT_TOOLBAR
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2715
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2716 // some forward declaration required by toolbar functions...
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2717 static BMessage * MenuMessage(vimmenu_T *menu);
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2718
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2719 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
2720 BBox(frame, name, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2721 {
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2722 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2723
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2724 VimToolbar::~VimToolbar()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2725 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2726 int32 count = fButtonsList.CountItems();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2727 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
2728 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
2729 fButtonsList.MakeEmpty();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2730
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2731 delete normalButtonsBitmap;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2732 delete grayedButtonsBitmap;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2733 normalButtonsBitmap = NULL;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2734 grayedButtonsBitmap = NULL;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2735 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2736
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2737 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2738 VimToolbar::AttachedToWindow()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2739 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2740 BBox::AttachedToWindow();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2741
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2742 SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2743 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2744
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2745 float
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2746 VimToolbar::ToolbarHeight() const
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2747 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2748 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
2749 return size + ToolbarMargin * 2 + ButtonMargin * 2 + 1;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2750 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2751
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2752 bool
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2753 VimToolbar::ModifyBitmapToGrayed(BBitmap *bitmap)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2754 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2755 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
2756 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
2757
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2758 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
2759 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
2760 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
2761 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
2762 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
2763 bits[i].alpha /= 4;
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2766 return true;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2767 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2768
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2769 bool
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2770 VimToolbar::PrepareButtonBitmaps()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2771 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2772 // 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
2773 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
2774 if (normalButtonsBitmap == NULL)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2775 // 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
2776 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
2777
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2778 if (normalButtonsBitmap == NULL)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2779 return false;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2780
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2781 BMessage archive;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2782 normalButtonsBitmap->Archive(&archive);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2783
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2784 grayedButtonsBitmap = new BBitmap(&archive);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2785 if (grayedButtonsBitmap == NULL)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2786 return false;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2787
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2788 // modify grayed bitmap
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2789 ModifyBitmapToGrayed(grayedButtonsBitmap);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2790
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2791 return true;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2792 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2793
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2794 BBitmap *VimToolbar::LoadVimBitmap(const char* fileName)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2795 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2796 BBitmap *bitmap = NULL;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2797
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2798 int mustfree = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2799 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
2800 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
2801 BString strPath((char*)runtimePath);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2802 strPath << "/bitmaps/" << fileName;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2803 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
2804 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2805
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2806 if (mustfree)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2807 vim_free(runtimePath);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2808
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2809 return bitmap;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2810 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2811
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2812 bool
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2813 VimToolbar::GetPictureFromBitmap(BPicture *pictureTo, int32 index, BBitmap *bitmapFrom, bool pressed)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2814 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2815 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
2816
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2817 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
2818
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2819 AddChild(&view);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2820 view.BeginPicture(pictureTo);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2821
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2822 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
2823 view.FillRect(view.Bounds());
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2824 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
2825
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2826 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
2827 BRect destination(source);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2828
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2829 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
2830 destination.OffsetBy(ButtonMargin, ButtonMargin);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2831
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2832 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
2833
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2834 if (pressed) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2835 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
2836 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
2837 size += ButtonMargin * 2 - 1;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2838 view.BeginLineArray(4);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2839 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
2840 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
2841 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
2842 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
2843 view.EndLineArray();
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2846 view.EndPicture();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2847 RemoveChild(&view);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2848
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2849 return true;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2850 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2851
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2852 bool
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2853 VimToolbar::AddButton(int32 index, vimmenu_T *menu)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2854 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2855 BPictureButton *button = NULL;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2856 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
2857 float size = normalButtonsBitmap ?
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2858 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
2859 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
2860 BPicture pictureOn;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2861 BPicture pictureOff;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2862 BPicture pictureGray;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2863
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2864 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
2865 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
2866 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
2867 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
2868 } else {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2869
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2870 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
2871 BBitmap *bitmap = NULL;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2872
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2873 if (menu->iconfile) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2874 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
2875 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
2876 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2877
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2878 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
2879 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
2880
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2881 if (bitmap == NULL)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2882 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
2883
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2884 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
2885 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
2886 ModifyBitmapToGrayed(bitmap);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2887 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
2888
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2889 delete bitmap;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2890 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2891
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2892 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
2893 &pictureOff, &pictureOn, MenuMessage(menu));
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2894
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2895 button->SetDisabledOn(&pictureGray);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2896 button->SetDisabledOff(&pictureGray);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2897
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2898 button->SetTarget(gui.vimTextArea);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2899
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2900 AddChild(button);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2901
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2902 menu->button = button;
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2905 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
2906 InvalidateLayout();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2907 return result;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2908 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2909
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2910 bool
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2911 VimToolbar::RemoveButton(vimmenu_T *menu)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2912 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2913 if (menu->button) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2914 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
2915 delete menu->button;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2916 menu->button = NULL;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2917 }
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2918 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2919 return true;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2920 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2921
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2922 bool
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2923 VimToolbar::GrayButton(vimmenu_T *menu, int grey)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2924 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2925 if (menu->button) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2926 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
2927 if (index >= 0)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2928 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
2929 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2930 return true;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2931 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2932
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2933 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2934 VimToolbar::InvalidateLayout()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2935 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2936 int32 offset = ToolbarMargin;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2937 int32 count = fButtonsList.CountItems();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2938 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
2939 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
2940 if (button) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2941 button->MoveTo(offset, ToolbarMargin);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2942 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
2943 } else
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2944 offset += ToolbarMargin * 3;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2945 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2946 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2947
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2948 #endif /*FEAT_TOOLBAR*/
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2949
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2950 #if defined(FEAT_GUI_TABLINE)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2951
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2952 float
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2953 VimTabLine::TablineHeight() const
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2954 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2955 // 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
2956 // 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
2957 return TabHeight(); // + ToolbarMargin;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2958 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2959
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2960 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2961 VimTabLine::MouseDown(BPoint point)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2962 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2963 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
2964 return;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2965
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2966 BMessage *m = Window()->CurrentMessage();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2967 assert(m);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2968
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2969 int32 buttons = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2970 m->FindInt32("buttons", &buttons);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2971
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2972 int32 clicks = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2973 m->FindInt32("clicks", &clicks);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2974
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2975 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
2976 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
2977 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
2978 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
2979 break;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2980 }
20152
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2983 int event = -1;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2984
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2985 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
2986 // 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
2987 event = TABLINE_MENU_NEW;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2988
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2989 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
2990 // 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
2991 // 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
2992 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
2993
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
2994 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
2995 // 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
2996 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
2997 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
2998 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
2999 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
3000
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3001 ConvertToScreen(&point);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3002 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
3003 if (item != NULL) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3004 event = item->Command();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3005 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3006
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3007 delete popUpMenu;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3008
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3009 } else {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3010 // default processing
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3011 BTabView::MouseDown(point);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3012 return;
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3015 if (event < 0)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3016 return;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3017
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3018 VimTablineMenuMsg tmm;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3019 tmm.index = index;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3020 tmm.event = event;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3021 write_port(gui.vdcmp, VimMsg::TablineMenu, &tmm, sizeof(tmm));
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3022 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3023
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3024 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3025 VimTabLine::VimTab::Select(BView* owner)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3026 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3027 BTab::Select(owner);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3028
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3029 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
3030 if (tabLine != NULL) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3031
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3032 int32 i = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3033 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
3034 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
3035 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3036
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3037 // 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
3038 if (i < tabLine->CountTabs()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3039 VimTablineMsg tm;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3040 tm.index = i + 1;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3041 write_port(gui.vdcmp, VimMsg::Tabline, &tm, sizeof(tm));
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3042 }
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3043 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3044 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3045
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3046 #endif // defined(FEAT_GUI_TABLINE)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3047
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3048 // ---------------- ----------------
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3049
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3050 // some global variables
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3051 static char appsig[] = "application/x-vnd.Haiku-Vim-8";
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3052 key_map *keyMap;
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3053 char *keyMapChars;
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3054 int main_exitcode = 127;
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3055
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3056 status_t
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3057 gui_haiku_process_event(bigtime_t timeout)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3058 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3059 struct VimMsg vm;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3060 int32 what;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3061 ssize_t size;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3062
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3063 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
3064 B_TIMEOUT, timeout);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3065
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3066 if (size >= 0) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3067 switch (what) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3068 case VimMsg::Key:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3069 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3070 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
3071 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
3072 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
3073 trash_input_buf();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3074 got_int = TRUE;
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3077 if (vm.u.Key.csi_escape)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3078 #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
3079 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3080 int i;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3081 char_u buf[2];
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3082
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3083 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
3084 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3085 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
3086 if (string[i] == CSI)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3087 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3088 // 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
3089 buf[0] = KS_EXTRA;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3090 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
3091 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
3092 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3093 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3094 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3095 #else
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3096 add_to_input_buf_csi(string, len);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3097 #endif
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3098 else
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3099 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
3100 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3101 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3102 case VimMsg::Resize:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3103 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
3104 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3105 case VimMsg::ScrollBar:
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 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3108 * 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
3109 * 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
3110 * 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
3111 * 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
3112 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3113 int32 oldCount =
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3114 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
3115 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
3116 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
3117 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
3118 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3119 break;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3120 #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
3121 case VimMsg::Menu:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3122 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
3123 break;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3124 #endif
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3125 case VimMsg::Mouse:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3126 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3127 int32 oldCount;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3128 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
3129 oldCount =
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3130 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
3131 else
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3132 oldCount = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3133 if (oldCount <= 1)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3134 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
3135 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
3136 vm.u.Mouse.modifiers);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3137 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3138 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3139 case VimMsg::MouseMoved:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3140 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3141 gui_mouse_moved(vm.u.MouseMoved.x, vm.u.MouseMoved.y);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3142 }
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3143 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3144 case VimMsg::Focus:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3145 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
3146 // 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
3147 // 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
3148 // 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
3149 if (gui.dragged_sb) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3150 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
3151 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3152 // 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
3153 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3154 case VimMsg::Refs:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3155 ::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
3156 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3157 case VimMsg::Tabline:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3158 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
3159 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3160 case VimMsg::TablineMenu:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3161 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
3162 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3163 default:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3164 // unrecognised message, ignore it
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3165 break;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3166 }
20152
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 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3170 * 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
3171 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3172 return size;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3173 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3174
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3175 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3176 * Here are some functions to protect access to ScreenLines[] and
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3177 * LineOffset[]. These are used from the window thread to respond
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3178 * to a Draw() callback. When that occurs, the window is already
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3179 * locked by the system.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3180 *
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3181 * Other code that needs to lock is any code that changes these
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3182 * variables. Other read-only access, or access merely to the
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3183 * contents of the screen buffer, need not be locked.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3184 *
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3185 * If there is no window, don't call Lock() but do succeed.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3186 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3187
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3188 int
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3189 vim_lock_screen()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3190 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3191 return !gui.vimWindow || gui.vimWindow->Lock();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3192 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3193
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3194 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3195 vim_unlock_screen()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3196 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3197 if (gui.vimWindow)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3198 gui.vimWindow->Unlock();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3199 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3200
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3201 #define RUN_BAPPLICATION_IN_NEW_THREAD 0
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3202
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3203 #if RUN_BAPPLICATION_IN_NEW_THREAD
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3204
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3205 int32
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3206 run_vimapp(void *args)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3207 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3208 VimApp app(appsig);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3209
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3210 gui.vimApp = &app;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3211 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
3212
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3213 return 0;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3214 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3215
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3216 #else
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3217
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3218 int32
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3219 call_main(void *args)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3220 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3221 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
3222
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3223 return main(ma->argc, ma->argv);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3224 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3225 #endif
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3226
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3227 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3228 * Parse the GUI related command-line arguments. Any arguments used are
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3229 * deleted from argv, and *argc is decremented accordingly. This is called
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3230 * when vim is started, whether or not the GUI has been started.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3231 */
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3232 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3233 gui_mch_prepare(
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3234 int *argc,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3235 char **argv)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3236 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3237 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3238 * 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
3239 * 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
3240 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3241 if (!gui.vimApp) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3242 thread_info tinfo;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3243 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
3244
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3245 // 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
3246 gui.vdcmp = create_port(B_MAX_PORT_COUNT, "vim VDCMP");
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3247
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3248 #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
3249 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
3250 tinfo.priority, NULL);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3251 if (tid >= B_OK) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3252 resume_thread(tid);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3253 } else {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3254 getout(1);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3255 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3256 #else
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3257 MainArgs ma = { *argc, argv };
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3258 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
3259 tinfo.priority, &ma);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3260 if (tid >= B_OK) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3261 VimApp app(appsig);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3262
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3263 gui.vimApp = &app;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3264 resume_thread(tid);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3265 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3266 * This is rather horrible.
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3267 * 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
3268 * 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
3269 * 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
3270 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3271 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
3272 // 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
3273 status_t dummy_exitcode;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3274 (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
3275
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3276 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3277 * 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
3278 * 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
3279 * 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
3280 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3281 exit(main_exitcode);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3282 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3283 #endif
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3284 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3285 // 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
3286 // 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
3287 gui.dofork = FALSE;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3288 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3289 * 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
3290 * 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
3291 * 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
3292 * 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
3293 * 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
3294 * of vim...
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3295 * 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
3296 * (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
3297 * 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
3298 * 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
3299 * 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
3300 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3301 if (!isatty(0)) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3302 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
3303
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3304 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
3305 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
3306 (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
3307 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
3308 gui.starting = TRUE;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3309 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3310 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3311
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3312 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3313 * Check if the GUI can be started. Called before gvimrc is sourced.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3314 * Return OK or FAIL.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3315 */
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3316 int
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3317 gui_mch_init_check(void)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3318 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3319 return OK; // TODO: GUI can always be started?
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3320 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3321
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3322 /*
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3323 * Initialise the GUI. Create all the windows, set up all the call-backs
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3324 * etc.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3325 */
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3326 int
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3327 gui_mch_init()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3328 {
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3329 display_errors();
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3330 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
3331 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
3332 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
3333 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
3334
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3335 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
3336 gui.scrollbar_height = (int) B_H_SCROLL_BAR_HEIGHT;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3337 #ifdef FEAT_MENU
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3338 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
3339 // correct for my default settings
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3340 #endif
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3341 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
3342
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3343 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
3344 return FAIL;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3345 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
3346
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3347 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
3348 if (!gui.vimWindow)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3349 return FAIL;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3350
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3351 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
3352
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3353 // 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
3354 // file)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3355 set_normal_colors();
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 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3358 * 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
3359 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3360 gui_check_colors();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3361
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3362 // 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
3363 // changed them)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3364 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
3365
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3366 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
3367
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3368 return OK;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3369 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3370
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3371 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3372 * Called when the foreground or background color has been changed.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3373 */
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3374 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3375 gui_mch_new_colors()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3376 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3377 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
3378
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3379 if (gui.vimWindow->Lock()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3380 gui.vimForm->SetViewColor(rgb);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3381 // 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
3382 gui.vimForm->Invalidate();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3383 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3384 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3385 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3386
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3387 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3388 * Open the GUI window which was created by a call to gui_mch_init().
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3389 */
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3390 int
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3391 gui_mch_open()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3392 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3393 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
3394 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
3395
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3396 // Actually open the window
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3397 if (gui.vimWindow->Lock()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3398 gui.vimWindow->Show();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3399 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3400 return OK;
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3403 return FAIL;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3404 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3405
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3406 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3407 gui_mch_exit(int vim_exitcode)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3408 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3409 if (gui.vimWindow) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3410 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
3411 gui.vimWindow->Lock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3412 gui.vimWindow->Quit();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3413 // Wait until it is truely gone
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3414 int32 exitcode;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3415 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
3416 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3417 delete_port(gui.vdcmp);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3418 #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
3419 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3420 * 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
3421 * 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
3422 * 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
3423 * 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
3424 */
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3425 #endif
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3426 if (gui.vimApp) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3427 VimTextAreaView::guiBlankMouse(false);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3428
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3429 main_exitcode = vim_exitcode;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3430 #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
3431 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
3432 int32 exitcode;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3433 gui.vimApp->Lock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3434 gui.vimApp->Quit();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3435 gui.vimApp->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3436 wait_for_thread(tid, &exitcode);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3437 #else
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3438 gui.vimApp->Lock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3439 gui.vimApp->Quit();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3440 gui.vimApp->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3441 // suicide
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3442 exit_thread(vim_exitcode);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3443 #endif
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3444 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3445 // If we are somehow still here, let mch_exit() handle things.
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3446 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3447
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3448 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3449 * Get the position of the top left corner of the window.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3450 */
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3451 int
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3452 gui_mch_get_winpos(int *x, int *y)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3453 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3454 if (gui.vimWindow->Lock()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3455 BRect r;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3456 r = gui.vimWindow->Frame();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3457 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3458 *x = (int)r.left;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3459 *y = (int)r.top;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3460 return OK;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3461 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3462 else
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3463 return FAIL;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3464 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3465
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3466 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3467 * Set the position of the top left corner of the window to the given
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3468 * coordinates.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3469 */
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3470 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3471 gui_mch_set_winpos(int x, int y)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3472 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3473 if (gui.vimWindow->Lock()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3474 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
3475 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3476 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3477 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3478
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3479 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3480 * Set the size of the window to the given width and height in pixels.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3481 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3482 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3483 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
3484 int width,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3485 int height,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3486 int min_width,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3487 int min_height,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3488 int base_width,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3489 int base_height,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3490 int direction) // TODO: utilize?
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3491 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3492 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3493 * 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
3494 * 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
3495 * 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
3496 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3497 if (gui.vimWindow->Lock()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3498 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
3499
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3500 // set size limits
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3501 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
3502
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3503 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
3504 &minHeight, &maxHeight);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3505 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
3506 min_height, maxHeight);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3507
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3508 /*
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3509 * Set the resizing alignment depending on font size.
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3510 */
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3511 gui.vimWindow->SetWindowAlignment(
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3512 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
3513 1, // int32 h,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3514 0, // int32 hOffset = 0,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3515 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
3516 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
3517 1, // int32 v = 0,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3518 0, // int32 vOffset = 0,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3519 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
3520 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
3521 );
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3522
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3523 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3524 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3525 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3527 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3528 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
3529 int *screen_w,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3530 int *screen_h)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3531 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3532 BRect frame;
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 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3535 BScreen screen(gui.vimWindow);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3536
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3537 if (screen.IsValid()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3538 frame = screen.Frame();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3539 } else {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3540 frame.right = 640;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3541 frame.bottom = 480;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3542 }
20152
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3545 // XXX approximations...
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3546 *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
3547 *screen_h = (int) frame.bottom - gui.scrollbar_height
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3548 #ifdef FEAT_MENU
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3549 - gui.menu_height
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3550 #endif
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3551 - 30;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3552 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3553
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3554 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3555 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
3556 int x,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3557 int y,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3558 int w,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3559 int h)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3560 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3561 if (!gui.vimTextArea)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3562 return;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3563
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3564 if (gui.vimWindow->Lock()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3565 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
3566 gui.vimTextArea->ResizeTo(w - PEN_WIDTH, h - PEN_WIDTH);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3567
20134
352701a626ed patch 8.2.0622: Haiku: GUI does not compile
Bram Moolenaar <Bram@vim.org>
parents: 19526
diff changeset
3568 #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
3569 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
3570 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
3571 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3572 #endif // FEAT_GUI_TABLINE
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3573
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3574 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3575 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3576 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3577
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3578
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3579 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3580 * Scrollbar stuff:
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3581 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3582
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3583 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3584 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
3585 scrollbar_T *sb,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3586 int flag)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3587 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3588 VimScrollBar *vsb = sb->id;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3589 if (gui.vimWindow->Lock()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3590 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3591 * 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
3592 * 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
3593 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3594 if (flag) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3595 if (vsb->IsHidden()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3596 vsb->Show();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3597 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3598 } else {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3599 if (!vsb->IsHidden()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3600 vsb->Hide();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3601 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3602 }
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3603 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3604 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3605 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3606
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3607 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3608 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
3609 scrollbar_T *sb,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3610 int val,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3611 int size,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3612 int max)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3613 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3614 if (gui.vimWindow->Lock()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3615 VimScrollBar *s = sb->id;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3616 if (max == 0) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3617 s->SetValue(0);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3618 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
3619 } else {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3620 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
3621 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
3622 #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
3623 max = max + 1 - size;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3624 #endif
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3625 if (max < s->Value()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3626 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3627 * 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
3628 * 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
3629 * therefore a ValueChanged() call.
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3630 * 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
3631 * it presumably is <= max.
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3632 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3633 s->SetValue(val);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3634 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
3635 } else {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3636 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3637 * 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
3638 * 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
3639 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3640 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
3641 s->SetValue(val);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3642 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3643 }
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3644 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3645 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3646 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3647
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3648 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3649 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
3650 scrollbar_T *sb,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3651 int x,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3652 int y,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3653 int w,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3654 int h)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3655 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3656 if (gui.vimWindow->Lock()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3657 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
3658 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
3659 VimScrollBar *vsb = sb->id;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3660 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
3661 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
3662 vsb->MoveTo(vsbx, vsby);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3663 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3664 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3665 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3666
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3667 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3668 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
3669 scrollbar_T *sb,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3670 int orient) // SBAR_VERT or SBAR_HORIZ
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3671 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3672 orientation posture =
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3673 (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
3674
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3675 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
3676 if (gui.vimWindow->Lock()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3677 vsb->SetTarget(gui.vimTextArea);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3678 vsb->Hide();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3679 gui.vimForm->AddChild(vsb);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3680 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3681 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3682 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3683
20134
352701a626ed patch 8.2.0622: Haiku: GUI does not compile
Bram Moolenaar <Bram@vim.org>
parents: 19526
diff changeset
3684 #if defined(FEAT_WINDOWS) || defined(FEAT_GUI_HAIKU) || defined(PROTO)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3685 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3686 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
3687 scrollbar_T *sb)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3688 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3689 if (gui.vimWindow->Lock()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3690 sb->id->RemoveSelf();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3691 delete sb->id;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3692 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3693 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3694 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3695 #endif
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3696
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3697 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3698 * Cursor does not flash
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3699 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3700 int
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3701 gui_mch_is_blink_off(void)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3702 {
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3703 return FALSE;
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3704 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3705
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3706 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3707 * Cursor blink functions.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3708 *
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3709 * This is a simple state machine:
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3710 * BLINK_NONE not blinking at all
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3711 * 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
3712 * BLINK_ON blinking, cursor is shown
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3713 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3714
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3715 #define BLINK_NONE 0
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3716 #define BLINK_OFF 1
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3717 #define BLINK_ON 2
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3718
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3719 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
3720 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
3721 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
3722 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
3723 static int blink_timer = 0;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3724
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3725 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3726 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
3727 long waittime,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3728 long on,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3729 long off)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3730 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3731 // TODO
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3732 blink_waittime = waittime;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3733 blink_ontime = on;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3734 blink_offtime = off;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3735 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3736
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3737 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3738 * Stop the cursor blinking. Show the cursor if it wasn't shown.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3739 */
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3740 void
20134
352701a626ed patch 8.2.0622: Haiku: GUI does not compile
Bram Moolenaar <Bram@vim.org>
parents: 19526
diff changeset
3741 gui_mch_stop_blink(int may_call_gui_update_cursor)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3742 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3743 // TODO
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3744 if (blink_timer != 0)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3745 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3746 // XtRemoveTimeOut(blink_timer);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3747 blink_timer = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3748 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3749 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
3750 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
3751 blink_state = BLINK_NONE;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3752 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3753
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3754 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3755 * Start the cursor blinking. If it was already blinking, this restarts the
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3756 * waiting time and shows the cursor.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3757 */
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3758 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3759 gui_mch_start_blink()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3760 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3761 // TODO
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3762 if (blink_timer != 0)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3763 ;// XtRemoveTimeOut(blink_timer);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3764 // 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
3765 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
3766 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3767 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
3768 blink_state = BLINK_ON;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3769 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
3770 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3771 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3772
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3773 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3774 * Initialise vim to use the font with the given name. Return FAIL if the font
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3775 * could not be loaded, OK otherwise.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3776 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3777 int
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3778 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
3779 char_u *font_name,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3780 int fontset)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3781 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3782 if (gui.vimWindow->Lock())
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3783 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3784 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
3785 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3786
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3787 return rc;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3788 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3789
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3790 return FAIL;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3791 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3792
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3793
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3794 int
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3795 gui_mch_adjust_charsize()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3796 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3797 return FAIL;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3798 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3799
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3800
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3801 int
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3802 gui_mch_font_dialog(font_family* family, font_style* style, float* size)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3803 {
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3804 #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
3805 // gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3806 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
3807 return dialog->Go();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3808 #else
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3809 return NOFONT;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3810 #endif // FEAT_GUI_DIALOG
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3811 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3812
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3813
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3814 GuiFont
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3815 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
3816 char_u *name,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3817 int giveErrorIfMissing)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3818 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3819 static VimFont *fontList = NULL;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3820
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3821 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
3822 return NOFONT;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3823
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3824 // 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
3825 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
3826 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
3827 font_family family = {0};
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3828 font_style style = {0};
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3829 float size = 0.f;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3830
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3831 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
3832 if (giveErrorIfMissing)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3833 semsg(_(e_font), name);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3834 return NOFONT;
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3837 bool useSelectGUI = false;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3838 if (name != NULL)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3839 if (STRCMP(name, "*") == 0) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3840 useSelectGUI = true;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3841 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
3842 } else
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3843 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
3844
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3845 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
3846 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
3847 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
3848 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
3849 (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
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 // replace underscores with spaces
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3853 char* end = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3854 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
3855 *end = ' ';
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3856
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3857 // 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
3858 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
3859 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
3860 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
3861 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
3862 if (style_s != 0)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3863 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
3864 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
3865
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3866 if (useSelectGUI) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3867 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
3868 return FAIL;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3869 // compose for further processing
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3870 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
3871 (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
3872 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
3873
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3874 // 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
3875 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
3876 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
3877 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
3878 vim_free(p_guifont);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3879 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
3880 // 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
3881 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
3882 if (*new_p_guifont == ' ')
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3883 *new_p_guifont = '_';
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3884 }
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3885 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3886
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3887 VimFont *flp;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3888 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
3889 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
3890 flp->refcount++;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3891 return (GuiFont)flp;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3892 }
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3893 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3894
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3895 VimFont *font = new VimFont();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3896 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
3897
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3898 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
3899 if (giveErrorIfMissing)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3900 semsg(_(e_font), font->name);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3901 delete font;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3902 return NOFONT;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3903 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3904
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3905 // 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
3906 font->next = fontList;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3907 fontList = font;
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 font->SetFamilyAndStyle(family, style);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3910 if (size > 0.f)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3911 font->SetSize(size);
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 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
3914 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
3915
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3916 return (GuiFont)font;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3917 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3918
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3919 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3920 * Set the current text font.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3921 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3922 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3923 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
3924 GuiFont font)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3925 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3926 if (gui.vimWindow->Lock()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3927 VimFont *vf = (VimFont *)font;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3928
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3929 gui.vimTextArea->SetFont(vf);
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 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
3932 font_height fh;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3933 vf->GetHeight(&fh);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3934 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
3935 + (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
3936 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
3937
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3938 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3939 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3940 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3941
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3942 // XXX TODO This is apparently never called...
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3943 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3944 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
3945 GuiFont font)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3946 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3947 if (font == NOFONT)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3948 return;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3949 VimFont *f = (VimFont *)font;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3950 if (--f->refcount <= 0) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3951 if (f->refcount < 0)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3952 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
3953 delete f;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3954 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3955 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3956
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3957 char_u *
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3958 gui_mch_get_fontname(GuiFont font, char_u *name)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3959 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3960 if (name == NULL)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3961 return NULL;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3962 return vim_strsave(name);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3963 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3964
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3965 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3966 * Adjust gui.char_height (after 'linespace' was changed).
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3967 */
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3968 int
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3969 gui_mch_adjust_charheight()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3970 {
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3971
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3972 // TODO: linespace support?
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3973
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3974 // #ifdef FEAT_XFONTSET
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3975 // if (gui.fontset != NOFONTSET)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3976 // {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3977 // 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
3978 // 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
3979 // + p_linespace / 2;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3980 // }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3981 // else
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3982 // #endif
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3983 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3984 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
3985 font_height fh = {0};
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3986 font->GetHeight(&fh);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3987 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
3988 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
3989 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
3990 return OK;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3991 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3992
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3993 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3994 * Display the saved error message(s).
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3995 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3996 #ifdef USE_MCH_ERRMSG
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3997 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3998 display_errors(void)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3999 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4000 char *p;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4001 char_u pError[256];
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4002
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4003 if (error_ga.ga_data == NULL)
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4004 return;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4005
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4006 // avoid putting up a message box with blanks only
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4007 for (p = (char *)error_ga.ga_data; *p; ++p)
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4008 if (!isspace(*p))
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4009 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4010 if (STRLEN(p) > 255)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4011 pError[0] = 255;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4012 else
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4013 pError[0] = STRLEN(p);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4014
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4015 STRNCPY(&pError[1], p, pError[0]);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4016 // ParamText(pError, nil, nil, nil);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4017 // Alert(128, nil);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4018 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4019 // TODO: handled message longer than 256 chars
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4020 // use auto-sizeable alert
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4021 // or dialog with scrollbars (TextEdit zone)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4022 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4023 ga_clear(&error_ga);
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4024 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4025 #endif
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
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
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4028 gui_mch_getmouse(int *x, int *y)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
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
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4032 /*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
4033 Window root, child;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4034 unsigned int mask;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4035
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4036 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
4037 &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
4038 *x = winx;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4039 *y = winy;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4040 } else*/ {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4041 *x = -1;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4042 *y = -1;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4043 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4044 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4045
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4046 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4047 gui_mch_mousehide(int hide)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4048 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4049 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
4050 // TODO
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4051 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4052
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4053 static int
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4054 hex_digit(int c)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4055 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4056 if (isdigit(c))
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4057 return c - '0';
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4058 c = TOLOWER_ASC(c);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4059 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
4060 return c - 'a' + 10;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4061 return -1000;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4062 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4063
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4064 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4065 * This function has been lifted from gui_w32.c and extended a bit.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4066 *
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4067 * Return the Pixel value (color) for the given color name.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4068 * Return INVALCOLOR for error.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4069 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4070 guicolor_T
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4071 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
4072 char_u *name)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4073 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4074 typedef struct GuiColourTable
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4075 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4076 const char *name;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4077 guicolor_T colour;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4078 } GuiColourTable;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4079
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4080 #define NSTATIC_COLOURS 50 // 32
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4081 #define NDYNAMIC_COLOURS 33
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4082 #define NCOLOURS (NSTATIC_COLOURS + NDYNAMIC_COLOURS)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4083
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4084 static GuiColourTable table[NCOLOURS] =
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4085 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4086 {"Black", RGB(0x00, 0x00, 0x00)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4087 {"DarkGray", RGB(0x80, 0x80, 0x80)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4088 {"DarkGrey", RGB(0x80, 0x80, 0x80)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4089 {"Gray", RGB(0xC0, 0xC0, 0xC0)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4090 {"Grey", RGB(0xC0, 0xC0, 0xC0)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4091 {"LightGray", RGB(0xD3, 0xD3, 0xD3)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4092 {"LightGrey", RGB(0xD3, 0xD3, 0xD3)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4093 {"Gray10", RGB(0x1A, 0x1A, 0x1A)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4094 {"Grey10", RGB(0x1A, 0x1A, 0x1A)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4095 {"Gray20", RGB(0x33, 0x33, 0x33)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4096 {"Grey20", RGB(0x33, 0x33, 0x33)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4097 {"Gray30", RGB(0x4D, 0x4D, 0x4D)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4098 {"Grey30", RGB(0x4D, 0x4D, 0x4D)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4099 {"Gray40", RGB(0x66, 0x66, 0x66)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4100 {"Grey40", RGB(0x66, 0x66, 0x66)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4101 {"Gray50", RGB(0x7F, 0x7F, 0x7F)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4102 {"Grey50", RGB(0x7F, 0x7F, 0x7F)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4103 {"Gray60", RGB(0x99, 0x99, 0x99)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4104 {"Grey60", RGB(0x99, 0x99, 0x99)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4105 {"Gray70", RGB(0xB3, 0xB3, 0xB3)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4106 {"Grey70", RGB(0xB3, 0xB3, 0xB3)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4107 {"Gray80", RGB(0xCC, 0xCC, 0xCC)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4108 {"Grey80", RGB(0xCC, 0xCC, 0xCC)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4109 {"Gray90", RGB(0xE5, 0xE5, 0xE5)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4110 {"Grey90", RGB(0xE5, 0xE5, 0xE5)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4111 {"White", RGB(0xFF, 0xFF, 0xFF)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4112 {"DarkRed", RGB(0x80, 0x00, 0x00)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4113 {"Red", RGB(0xFF, 0x00, 0x00)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4114 {"LightRed", RGB(0xFF, 0xA0, 0xA0)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4115 {"DarkBlue", RGB(0x00, 0x00, 0x80)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4116 {"Blue", RGB(0x00, 0x00, 0xFF)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4117 {"LightBlue", RGB(0xA0, 0xA0, 0xFF)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4118 {"DarkGreen", RGB(0x00, 0x80, 0x00)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4119 {"Green", RGB(0x00, 0xFF, 0x00)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4120 {"LightGreen", RGB(0xA0, 0xFF, 0xA0)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4121 {"DarkCyan", RGB(0x00, 0x80, 0x80)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4122 {"Cyan", RGB(0x00, 0xFF, 0xFF)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4123 {"LightCyan", RGB(0xA0, 0xFF, 0xFF)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4124 {"DarkMagenta", RGB(0x80, 0x00, 0x80)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4125 {"Magenta", RGB(0xFF, 0x00, 0xFF)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4126 {"LightMagenta", RGB(0xFF, 0xA0, 0xFF)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4127 {"Brown", RGB(0x80, 0x40, 0x40)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4128 {"Yellow", RGB(0xFF, 0xFF, 0x00)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4129 {"LightYellow", RGB(0xFF, 0xFF, 0xA0)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4130 {"DarkYellow", RGB(0xBB, 0xBB, 0x00)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4131 {"SeaGreen", RGB(0x2E, 0x8B, 0x57)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4132 {"Orange", RGB(0xFF, 0xA5, 0x00)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4133 {"Purple", RGB(0xA0, 0x20, 0xF0)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4134 {"SlateBlue", RGB(0x6A, 0x5A, 0xCD)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4135 {"Violet", RGB(0xEE, 0x82, 0xEE)},
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4136 // NOTE: some entries are zero-allocated for NDDYNAMIC_COLORS
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4137 // in this table!
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4138 };
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4139
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4140 static int endColour = NSTATIC_COLOURS;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4141 static int newColour = NSTATIC_COLOURS;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4142
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4143 int r, g, b;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4144 int i;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4145
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4146 if (name[0] == '#' && STRLEN(name) == 7)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4147 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4148 // Name is in "#rrggbb" format
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4149 r = hex_digit(name[1]) * 16 + hex_digit(name[2]);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4150 g = hex_digit(name[3]) * 16 + hex_digit(name[4]);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4151 b = hex_digit(name[5]) * 16 + hex_digit(name[6]);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4152 if (r < 0 || g < 0 || b < 0)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4153 return INVALCOLOR;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4154 return RGB(r, g, b);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4155 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4156 else
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4157 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4158 // Check if the name is one of the colours we know
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4159 for (i = 0; i < endColour; i++)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4160 if (STRICMP(name, table[i].name) == 0)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4161 return table[i].colour;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4162 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4163
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4164 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4165 * Last attempt. Look in the file "$VIMRUNTIME/rgb.txt".
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4166 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4167 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4168 #define LINE_LEN 100
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4169 FILE *fd;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4170 char line[LINE_LEN];
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4171 char_u *fname;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4172
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4173 fname = expand_env_save((char_u *)"$VIMRUNTIME/rgb.txt");
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4174 if (fname == NULL)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4175 return INVALCOLOR;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4176
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4177 fd = fopen((char *)fname, "rt");
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4178 vim_free(fname);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4179 if (fd == NULL)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4180 return INVALCOLOR;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4181
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4182 while (!feof(fd))
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4183 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4184 int len;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4185 int pos;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4186 char *colour;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4187
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4188 fgets(line, LINE_LEN, fd);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4189 len = strlen(line);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4190
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4191 if (len <= 1 || line[len-1] != '\n')
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4192 continue;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4193
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4194 line[len-1] = '\0';
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4195
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4196 i = sscanf(line, "%d %d %d %n", &r, &g, &b, &pos);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4197 if (i != 3)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4198 continue;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4199
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4200 colour = line + pos;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4201
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4202 if (STRICMP(colour, name) == 0)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4203 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4204 fclose(fd);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4205 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4206 * Now remember this colour in the table.
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4207 * A LRU scheme might be better but this is simpler.
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4208 * Or could use a growing array.
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4209 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4210 guicolor_T gcolour = RGB(r,g,b);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4211
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4212 // NOTE: see note above in table allocation! We are working here with
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4213 // dynamically allocated names, not constant ones!
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4214 vim_free((char*)table[newColour].name);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4215 table[newColour].name = (char *)vim_strsave((char_u *)colour);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4216 table[newColour].colour = gcolour;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4217
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4218 newColour++;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4219 if (newColour >= NCOLOURS)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4220 newColour = NSTATIC_COLOURS;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4221 if (endColour < NCOLOURS)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4222 endColour = newColour;
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 return gcolour;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4225 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4226 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4227
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4228 fclose(fd);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4229 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4230
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4231 return INVALCOLOR;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4232 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4233
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4234 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4235 * Set the current text foreground color.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4236 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4237 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4238 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
4239 guicolor_T color)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4240 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4241 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
4242 if (gui.vimWindow->Lock()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4243 gui.vimTextArea->SetHighColor(rgb);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4244 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4245 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4246 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4247
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4248 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4249 * Set the current text background color.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4250 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4251 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4252 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
4253 guicolor_T color)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4254 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4255 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
4256 if (gui.vimWindow->Lock()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4257 gui.vimTextArea->SetLowColor(rgb);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4258 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4259 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4260 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4261
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4262 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4263 * Set the current text special color.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4264 */
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4265 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4266 gui_mch_set_sp_color(guicolor_T color)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4267 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4268 // prev_sp_color = color;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4269 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4270
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4271 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4272 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
4273 int row,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4274 int col,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4275 char_u *s,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4276 int len,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4277 int flags)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4278 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4279 if (gui.vimWindow->Lock()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4280 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
4281 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4282 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4283 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4284
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4285 guicolor_T
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4286 gui_mch_get_rgb_color(int r, int g, int b)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4287 {
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4288 return gui_get_rgb_color_cmn(r, g, b);
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4289 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4290
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4291
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4292 // Return OK if the key with the termcap name "name" is supported.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4293 int
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4294 gui_mch_haskey(
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4295 char_u *name)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4296 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4297 int i;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4298
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4299 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
4300 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
4301 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
4302 return OK;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4303 return FAIL;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4304 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4305
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4306 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4307 gui_mch_beep()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4308 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4309 ::beep();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4310 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4311
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4312 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4313 gui_mch_flash(int msec)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4314 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4315 // 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
4316
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4317 if (gui.vimWindow->Lock()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4318 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
4319
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4320 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
4321 gui.vimTextArea->FillRect(rect);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4322 gui.vimTextArea->Sync();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4323 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
4324 gui.vimTextArea->FillRect(rect);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4325 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
4326 gui.vimTextArea->Flush();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4327 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4328 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4329 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4330
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4331 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4332 * Invert a rectangle from row r, column c, for nr rows and nc columns.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4333 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4334 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4335 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
4336 int r,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4337 int c,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4338 int nr,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4339 int nc)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4340 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4341 BRect rect;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4342 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
4343 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
4344 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
4345 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
4346
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4347 if (gui.vimWindow->Lock()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4348 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
4349 gui.vimTextArea->FillRect(rect);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4350 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
4351 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4352 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4353 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4354
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4355 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4356 * Iconify the GUI window.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4357 */
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4358 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4359 gui_mch_iconify()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4360 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4361 if (gui.vimWindow->Lock()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4362 gui.vimWindow->Minimize(true);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4363 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4364 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4365 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4366
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4367 #if defined(FEAT_EVAL) || defined(PROTO)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4368 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4369 * Bring the Vim window to the foreground.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4370 */
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4371 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4372 gui_mch_set_foreground(void)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4373 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4374 // TODO
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4375 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4376 #endif
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4377
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4378 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4379 * Set the window title
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4380 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4381 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4382 gui_mch_settitle(
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4383 char_u *title,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4384 char_u *icon)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4385 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4386 if (gui.vimWindow->Lock()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4387 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
4388 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4389 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4390 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4391
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4392 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4393 * Draw a cursor without focus.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4394 */
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4395 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4396 gui_mch_draw_hollow_cursor(guicolor_T color)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4397 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4398 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
4399
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4400 BRect r;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4401 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
4402 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
4403 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
4404 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
4405 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
4406 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
4407
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4408 if (gui.vimWindow->Lock()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4409 gui.vimTextArea->StrokeRect(r);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4410 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4411 // gui_mch_flush();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4412 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4413 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4414
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4415 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4416 * Draw part of a cursor, only w pixels wide, and h pixels high.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4417 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4418 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4419 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
4420 int w,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4421 int h,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4422 guicolor_T color)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4423 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4424 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
4425
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4426 BRect r;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4427 r.left =
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4428 #ifdef FEAT_RIGHTLEFT
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4429 // 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
4430 CURSOR_BAR_RIGHT ? FILL_X(gui.col + 1) - w :
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4431 #endif
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4432 FILL_X(gui.col);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4433 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
4434 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
4435 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
4436
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4437 if (gui.vimWindow->Lock()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4438 gui.vimTextArea->FillRect(r);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4439 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4440 // gui_mch_flush();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4441 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4442 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4443
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4444 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4445 * Catch up with any queued events. This may put keyboard input into the
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4446 * input buffer, call resize call-backs, trigger timers etc. If there is
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4447 * nothing in the event queue (& no timers pending), then we return
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4448 * immediately.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4449 */
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4450 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4451 gui_mch_update()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4452 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4453 gui_mch_flush();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4454 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
4455 !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
4456 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
4457 /* nothing */ ;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4458 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4459
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4460 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4461 * GUI input routine called by gui_wait_for_chars(). Waits for a character
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4462 * from the keyboard.
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4463 * wtime == -1 Wait forever.
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4464 * 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
4465 * wtime > 0 Wait wtime milliseconds for a character.
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4466 * Returns OK if a character was found to be available within the given time,
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4467 * or FAIL otherwise.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4468 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4469 int
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4470 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
4471 int wtime)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4472 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4473 int focus;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4474 bigtime_t until, timeout;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4475 status_t st;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4476
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4477 if (wtime >= 0) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4478 timeout = wtime * 1000;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4479 until = system_time() + timeout;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4480 } else {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4481 timeout = B_INFINITE_TIMEOUT;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4482 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4483
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4484 focus = gui.in_focus;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4485 for (;;)
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 // 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
4488 if (gui.in_focus != focus)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4489 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4490 if (gui.in_focus)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4491 gui_mch_start_blink();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4492 else
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4493 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
4494 focus = gui.in_focus;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4495 }
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4496
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4497 gui_mch_flush();
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 * 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
4500 * 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
4501 * 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
4502 * 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
4503 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4504 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
4505
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4506 if (input_available())
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4507 return OK;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4508 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
4509 return FAIL;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4510
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 * 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
4513 * next event.
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4514 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4515 if (wtime >= 0) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4516 timeout = until - system_time();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4517 if (timeout < 0)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4518 break;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4519 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4520 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4521 return FAIL;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4522
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4523 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4524
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4525 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4526 * Output routines.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4527 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4528
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4529 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4530 * Flush any output to the screen. This is typically called before
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4531 * the app goes to sleep.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4532 */
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4533 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4534 gui_mch_flush()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4535 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4536 // 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
4537 if (gui.vimWindow->Lock()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4538 gui.vimWindow->Flush();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4539 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4540 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4541 return;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4542 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4543
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4544 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4545 * Clear a rectangular region of the screen from text pos (row1, col1) to
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4546 * (row2, col2) inclusive.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4547 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4548 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4549 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
4550 int row1,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4551 int col1,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4552 int row2,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4553 int col2)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4554 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4555 if (gui.vimWindow->Lock()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4556 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
4557 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4558 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4559 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4560
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4561 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4562 gui_mch_clear_all()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4563 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4564 if (gui.vimWindow->Lock()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4565 gui.vimTextArea->mchClearAll();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4566 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4567 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4568 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4569
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4570 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4571 * Delete the given number of lines from the given row, scrolling up any
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4572 * text further down within the scroll region.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4573 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4574 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4575 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
4576 int row,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4577 int num_lines)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4578 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4579 gui.vimTextArea->mchDeleteLines(row, num_lines);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4580 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4581
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4582 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4583 * Insert the given number of lines before the given row, scrolling down any
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4584 * following text within the scroll region.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4585 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4586 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4587 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
4588 int row,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4589 int num_lines)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4590 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4591 gui.vimTextArea->mchInsertLines(row, num_lines);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4592 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4593
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4594 #if defined(FEAT_MENU) || defined(PROTO)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4595 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4596 * Menu stuff.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4597 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4598
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4599 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4600 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
4601 int flag)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4602 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4603 if (gui.vimWindow->Lock())
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4604 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4605 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
4606 menubar->SetEnabled(flag);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4607 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4608 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4609 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4610
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4611 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4612 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
4613 int x,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4614 int y,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4615 int w,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4616 int h)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4617 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4618 // It will be in the right place anyway
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4619 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4620
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4621 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4622 * Add a sub menu to the menu bar.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4623 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4624 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4625 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
4626 vimmenu_T *menu,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4627 int idx)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4628 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4629 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
4630
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4631 // 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
4632 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
4633 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
4634 menu->submenu_id = popUpMenu;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4635 menu->id = NULL;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4636 return;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4637 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4638
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4639 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
4640 || (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
4641 return;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4642
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4643 if (gui.vimWindow->Lock())
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4644 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4645 // 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
4646 // 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
4647 //
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4648 // 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
4649 // 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
4650 //
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4651 // 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
4652
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4653 BMenu *tmp;
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 if ( parent )
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4656 tmp = parent->submenu_id;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4657 else
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4658 tmp = gui.vimForm->MenuBar();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4659 // 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
4660 // 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
4661
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4662 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
4663
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4664 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
4665
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4666 menu->submenu_id = bmenu;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4667
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4668 // 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
4669 tmp->AddItem(bmenu);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4670
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4671 // Now its safe to query the menu for the associated MenuItem....
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4672 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
4673
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4674 }
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4675 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4676 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4677 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4678
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4679 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4680 gui_mch_toggle_tearoffs(int enable)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4681 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4682 // no tearoff menus
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4683 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4684
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4685 static BMessage *
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4686 MenuMessage(vimmenu_T *menu)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4687 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4688 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
4689 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
4690
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4691 return m;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4692 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4693
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4694 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4695 * Add a menu item to a menu
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4696 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4697 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4698 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
4699 vimmenu_T *menu,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4700 int idx)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4701 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4702 int mnemonic = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4703 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
4704
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4705 // TODO: use menu->actext
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4706 // 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
4707 // 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
4708 //
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4709 // Punt for Now...
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4710 // 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
4711 if (gui.vimWindow->Lock())
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4712 {
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4713 #ifdef FEAT_TOOLBAR
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4714 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
4715 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
4716 if (toolbar != NULL) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4717 toolbar->AddButton(idx, menu);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4718 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4719 } else
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4720 #endif
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4721
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4722 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
4723 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
4724 BSeparatorItem *item = new BSeparatorItem();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4725 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
4726 menu->id = item;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4727 menu->submenu_id = NULL;
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 else {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4730 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
4731 MenuMessage(menu));
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4732 item->SetTarget(gui.vimTextArea);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4733 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
4734 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
4735 menu->id = item;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4736 menu->submenu_id = NULL;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4737 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4738 }
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4739 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4740 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4741 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4742
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4743 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4744 * Destroy the machine specific menu widget.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4745 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4746 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4747 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
4748 vimmenu_T *menu)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4749 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4750 if (gui.vimWindow->Lock())
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4751 {
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4752 #ifdef FEAT_TOOLBAR
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4753 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
4754 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
4755 if (toolbar != NULL) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4756 toolbar->RemoveButton(menu);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4757 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4758 } else
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4759 #endif
20152
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 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
4762 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4763 * 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
4764 * 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
4765 * 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
4766 * (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
4767 * removed and deleted before).
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4768 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4769 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
4770 if (bmenu)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4771 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4772 bmenu->RemoveItem(menu->id);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4773 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4774 * 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
4775 * 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
4776 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4777 if (bmenu == gui.vimForm->MenuBar() && bmenu->CountItems() == 0)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4778 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4779 bmenu->ResizeTo(-MENUBAR_MARGIN, -MENUBAR_MARGIN);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
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 delete menu->id;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4783 menu->id = NULL;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4784 menu->submenu_id = NULL;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4785
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4786 gui.menu_height = (int) gui.vimForm->MenuHeight();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4787 }
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4788 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4789 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4790 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4791
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4792 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4793 * Make a menu either grey or not grey.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4794 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4795 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4796 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
4797 vimmenu_T *menu,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4798 int grey)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4799 {
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4800 #ifdef FEAT_TOOLBAR
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4801 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
4802 if (gui.vimWindow->Lock()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4803 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
4804 if (toolbar != NULL) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4805 toolbar->GrayButton(menu, grey);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4806 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4807 gui.vimWindow->Unlock();
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 } else
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4810 #endif
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4811 if (menu->id != NULL)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4812 menu->id->SetEnabled(!grey);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4813 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4814
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4815 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4816 * Make menu item hidden or not hidden
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4817 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4818 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4819 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
4820 vimmenu_T *menu,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4821 int hidden)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4822 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4823 if (menu->id != NULL)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4824 menu->id->SetEnabled(!hidden);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4825 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4826
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4827 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4828 * This is called after setting all the menus to grey/hidden or not.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4829 */
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4830 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4831 gui_mch_draw_menubar()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4832 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4833 // Nothing to do in BeOS
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4834 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4835
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4836 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4837 gui_mch_show_popupmenu(vimmenu_T *menu)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4838 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4839 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
4840 return;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4841
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4842 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
4843 if (popupMenu == NULL)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4844 return;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4845
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4846 BPoint point;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4847 if (gui.vimWindow->Lock()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4848 uint32 buttons = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4849 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
4850 gui.vimTextArea->ConvertToScreen(&point);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4851 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4852 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4853 popupMenu->Go(point, true);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4854 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4855
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4856 #endif // FEAT_MENU
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4857
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4858 // Mouse stuff
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4859
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4860 #ifdef FEAT_CLIPBOARD
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4861 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4862 * Clipboard stuff, for cutting and pasting text to other windows.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4863 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4864 char textplain[] = "text/plain";
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4865 char vimselectiontype[] = "application/x-vnd.Rhialto-Vim-selectiontype";
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4866
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4867 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4868 * Get the current selection and put it in the clipboard register.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4869 */
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4870 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4871 clip_mch_request_selection(Clipboard_T *cbd)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4872 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4873 if (be_clipboard->Lock())
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 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
4876 // m->PrintToStream();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4877
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4878 char_u *string = NULL;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4879 ssize_t stringlen = -1;
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 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
4882 (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
4883 || m->FindString("text", (const char **)&string) == B_OK)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4884 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4885 if (stringlen == -1)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4886 stringlen = STRLEN(string);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4887
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4888 int type;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4889 char *seltype;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4890 ssize_t seltypelen;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4891
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4892 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4893 * 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
4894 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4895 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
4896 (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
4897 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4898 switch (*seltype)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4899 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4900 default:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4901 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
4902 case 'C': type = MCHAR; break;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4903 #ifdef FEAT_VISUAL
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4904 case 'B': type = MBLOCK; break;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4905 #endif
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4906 }
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4907 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4908 else
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4909 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4910 // 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
4911 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
4912 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4913 clip_yank_selection(type, string, (long)stringlen, cbd);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4914 }
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4915 be_clipboard->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4916 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4917 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4918 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4919 * Make vim the owner of the current selection.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4920 */
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4921 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4922 clip_mch_lose_selection(Clipboard_T *cbd)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4923 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4924 // Nothing needs to be done here
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4925 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4926
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4927 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4928 * Make vim the owner of the current selection. Return OK upon success.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4929 */
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4930 int
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4931 clip_mch_own_selection(Clipboard_T *cbd)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4932 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4933 /*
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4934 * 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
4935 * 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
4936 */
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4937 return FAIL;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4938 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4939
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4940 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4941 * Send the current selection to the clipboard.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4942 */
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4943 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4944 clip_mch_set_selection(Clipboard_T *cbd)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4945 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4946 if (be_clipboard->Lock())
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4947 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4948 be_clipboard->Clear();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4949 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
4950 assert(m);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4951
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4952 // 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
4953 cbd->owned = TRUE;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4954 clip_get_selection(cbd);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4955 cbd->owned = FALSE;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4956
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4957 char_u *str = NULL;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4958 long_u count;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4959 int type;
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 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
4962
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4963 if (type < 0)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4964 return;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4965
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4966 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
4967
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4968 // Add type of selection
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4969 char vtype;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4970 switch (type)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4971 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4972 default:
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4973 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
4974 case MCHAR: vtype = 'C'; break;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4975 #ifdef FEAT_VISUAL
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4976 case MBLOCK: vtype = 'B'; break;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4977 #endif
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4978 }
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4979 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
4980
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4981 vim_free(str);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4982
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4983 be_clipboard->Commit();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4984 be_clipboard->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
4985 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4986 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4987
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4988 #endif // FEAT_CLIPBOARD
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4989
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4990 #ifdef FEAT_BROWSE
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4991 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4992 * Pop open a file browser and return the file selected, in allocated memory,
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4993 * or NULL if Cancel is hit.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4994 * saving - TRUE if the file will be saved to, FALSE if it will be opened.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4995 * title - Title message for the file browser dialog.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4996 * dflt - Default name of file.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4997 * ext - Default extension to be added to files without extensions.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4998 * initdir - directory in which to open the browser (NULL = current dir)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4999 * filter - Filter for matched files to choose from.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5000 * Has a format like this:
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5001 * "C Files (*.c)\0*.c\0"
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5002 * "All Files\0*.*\0\0"
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5003 * If these two strings were concatenated, then a choice of two file
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5004 * filters will be selectable to the user. Then only matching files will
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5005 * be shown in the browser. If NULL, the default allows all files.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5006 *
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5007 * *NOTE* - the filter string must be terminated with TWO nulls.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5008 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5009 char_u *
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5010 gui_mch_browse(
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5011 int saving,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5012 char_u *title,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5013 char_u *dflt,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5014 char_u *ext,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5015 char_u *initdir,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5016 char_u *filter)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5017 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5018 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
5019 NULL, NULL, 0, false,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5020 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
5021
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5022 gui.vimApp->fBrowsedPath.Unset();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5023
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5024 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
5025 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
5026
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5027 gui.vimApp->fFilePanel->Show();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5028
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5029 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
5030
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5031 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
5032
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5033 char_u *fileName = NULL;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5034 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
5035 if (result == B_OK) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5036 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
5037 } else
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5038 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
5039 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
5040 result, strerror(result));
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5041 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5042
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5043 delete gui.vimApp->fFilePanel;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5044 gui.vimApp->fFilePanel = NULL;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5045
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5046 return fileName;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5047 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5048 #endif // FEAT_BROWSE
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5049
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5050
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5051 #if defined(FEAT_GUI_DIALOG)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5052
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5053 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5054 * 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
5055 * 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
5056 * 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
5057 * 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
5058 * buttons = '\n' separated list of button captions, default first.
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5059 * dfltbutton = number of default button.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5060 *
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5061 * 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
5062 * 2 for the second, etc.
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5063 *
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5064 * 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
5065 * -1 for unexpected error
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5066 *
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5067 * If stubbing out this fn, return 1.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5068 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5069
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5070 int
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5071 gui_mch_dialog(
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5072 int type,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5073 char_u *title,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5074 char_u *message,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5075 char_u *buttons,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5076 int dfltbutton,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5077 char_u *textfield,
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5078 int ex_cmd)
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5079 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5080 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
5081 (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
5082 return dialog->Go();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5083 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5084
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5085 #endif // FEAT_GUI_DIALOG
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5086
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5087
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5088 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5089 * Return the RGB value of a pixel as long.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5090 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5091 guicolor_T
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5092 gui_mch_get_rgb(guicolor_T pixel)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5093 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5094 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
5095
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5096 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
5097 + (rgb.blue & 0xff);
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5098 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5099
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5100 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5101 gui_mch_setmouse(int x, int y)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5102 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5103 TRACE();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5104 // TODO
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5105 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5106
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5107 #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
5108 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5109 im_set_position(int row, int col)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5110 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5111 if (gui.vimWindow->Lock())
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5112 {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5113 gui.vimTextArea->DrawIMString();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5114 gui.vimWindow->Unlock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5115 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5116 return;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5117 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5118 #endif
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5119
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5120 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5121 gui_mch_show_toolbar(int showit)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5122 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5123 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
5124 gui.toolbar_height = (toolbar && showit) ? toolbar->ToolbarHeight() : 0.;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5125 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5126
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5127 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5128 gui_mch_set_toolbar_pos(int x, int y, int w, int h)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5129 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5130 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
5131 if (toolbar != NULL) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5132 if (gui.vimWindow->Lock()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5133 toolbar->MoveTo(x, y);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5134 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
5135 gui.vimWindow->Unlock();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5136 }
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5137 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5138 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5139
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5140 #if defined(FEAT_GUI_TABLINE) || defined(PROTO)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5141
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5142 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5143 * Show or hide the tabline.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5144 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5145 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5146 gui_mch_show_tabline(int showit)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5147 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5148 VimTabLine *tabLine = gui.vimForm->TabLine();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5149
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5150 if (tabLine == NULL)
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5151 return;
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5152
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5153 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
5154 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
5155 gui.tabline_height = gui.vimForm->TablineHeight();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5156 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5157 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5158
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5159 void
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5160 gui_mch_set_tabline_pos(int x, int y, int w, int h)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5161 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5162 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
5163 if (tabLine != NULL) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5164 if (gui.vimWindow->Lock()) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5165 tabLine->MoveTo(x, y);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5166 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
5167 gui.vimWindow->Unlock();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5168 }
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5169 }
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5170 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5171
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5172 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5173 * Return TRUE when tabline is displayed.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5174 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5175 int
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5176 gui_mch_showing_tabline()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5177 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5178 VimTabLine *tabLine = gui.vimForm->TabLine();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5179 return tabLine != NULL && gui.vimForm->IsShowingTabLine();
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5180 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5181
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5182 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5183 * Update the labels of the tabline.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5184 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5185 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5186 gui_mch_update_tabline()
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5187 {
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5188 tabpage_T *tp;
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5189 int nr = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5190 int curtabidx = 0;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5191
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5192 VimTabLine *tabLine = gui.vimForm->TabLine();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5193
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5194 if (tabLine == NULL)
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5195 return;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5196
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5197 gui.vimWindow->Lock();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5198
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5199 // Add a label for each tab page. They all contain the same text area.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5200 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
5201 if (tp == curtab)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5202 curtabidx = nr;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5203
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5204 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
5205
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5206 if (tab == NULL) {
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5207 tab = new VimTabLine::VimTab();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5208 tabLine->AddTab(NULL, tab);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5209 }
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5210
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5211 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
5212 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
5213 tabLine->Invalidate();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5214 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5215
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5216 // 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
5217 while (nr < tabLine->CountTabs())
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5218 tabLine->RemoveTab(nr);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5219
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5220 if (tabLine->Selection() != curtabidx)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5221 tabLine->Select(curtabidx);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5222
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5223 gui.vimWindow->Unlock();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5224 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5225
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5226 /*
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5227 * Set the current tab to "nr". First tab is 1.
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5228 */
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5229 void
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5230 gui_mch_set_curtab(int nr)
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5231 {
20152
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5232 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
5233 if (tabLine == NULL)
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5234 return;
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5235
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5236 gui.vimWindow->Lock();
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5237
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5238 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
5239 tabLine->Select(nr -1);
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5240
bac01efdf059 patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents: 20134
diff changeset
5241 gui.vimWindow->Unlock();
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5242 }
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5243
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5244 #endif // FEAT_GUI_TABLINE