7
|
1 /* vi:set ts=8 sts=4 sw=4:
|
|
2 *
|
|
3 * VIM - Vi IMproved by Bram Moolenaar
|
|
4 *
|
|
5 * QNX port by Julian Kinraid
|
|
6 *
|
|
7 * Do ":help uganda" in Vim to read copying and usage conditions.
|
|
8 * Do ":help credits" in Vim to see a list of people who contributed.
|
|
9 */
|
|
10
|
|
11 /*
|
|
12 * os_qnx.c
|
|
13 */
|
|
14
|
|
15 #include "vim.h"
|
|
16
|
|
17
|
|
18 #if defined(FEAT_GUI_PHOTON)
|
|
19 int is_photon_available;
|
|
20 #endif
|
|
21
|
|
22 void qnx_init()
|
|
23 {
|
|
24 #if defined(FEAT_GUI_PHOTON)
|
|
25 PhChannelParms_t parms;
|
|
26
|
3100
|
27 memset(&parms, 0, sizeof(parms));
|
7
|
28 parms.flags = Ph_DYNAMIC_BUFFER;
|
|
29
|
3100
|
30 is_photon_available = (PhAttach(NULL, &parms) != NULL) ? TRUE : FALSE;
|
7
|
31 #endif
|
|
32 }
|
|
33
|
|
34 #if (defined(FEAT_GUI_PHOTON) && defined(FEAT_CLIPBOARD)) || defined(PROTO)
|
|
35
|
|
36 #define CLIP_TYPE_VIM "VIMTYPE"
|
|
37 #define CLIP_TYPE_TEXT "TEXT"
|
|
38
|
|
39 /* Turn on the clipboard for a console vim when photon is running */
|
|
40 void qnx_clip_init()
|
|
41 {
|
3100
|
42 if (is_photon_available == TRUE && !gui.in_use)
|
|
43 clip_init(TRUE);
|
7
|
44 }
|
|
45
|
|
46 /*****************************************************************************/
|
|
47 /* Clipboard */
|
|
48
|
|
49 /* No support for owning the clipboard */
|
|
50 int
|
3100
|
51 clip_mch_own_selection(VimClipboard *cbd)
|
7
|
52 {
|
|
53 return FALSE;
|
|
54 }
|
|
55
|
|
56 void
|
3100
|
57 clip_mch_lose_selection(VimClipboard *cbd)
|
7
|
58 {
|
|
59 }
|
|
60
|
|
61 void
|
3100
|
62 clip_mch_request_selection(VimClipboard *cbd)
|
7
|
63 {
|
|
64 int type = MLINE, clip_length = 0, is_type_set = FALSE;
|
|
65 void *cbdata;
|
|
66 PhClipHeader *clip_header;
|
|
67 char_u *clip_text = NULL;
|
|
68
|
3100
|
69 cbdata = PhClipboardPasteStart(PhInputGroup(NULL));
|
|
70 if (cbdata != NULL)
|
7
|
71 {
|
|
72 /* Look for the vim specific clip first */
|
3100
|
73 clip_header = PhClipboardPasteType(cbdata, CLIP_TYPE_VIM);
|
|
74 if (clip_header != NULL && clip_header->data != NULL)
|
7
|
75 {
|
3100
|
76 switch(*(char *) clip_header->data)
|
7
|
77 {
|
|
78 default: /* fallthrough to line type */
|
|
79 case 'L': type = MLINE; break;
|
|
80 case 'C': type = MCHAR; break;
|
|
81 #ifdef FEAT_VISUAL
|
|
82 case 'B': type = MBLOCK; break;
|
|
83 #endif
|
|
84 }
|
|
85 is_type_set = TRUE;
|
|
86 }
|
|
87
|
|
88 /* Try for just normal text */
|
3100
|
89 clip_header = PhClipboardPasteType(cbdata, CLIP_TYPE_TEXT);
|
|
90 if (clip_header != NULL)
|
7
|
91 {
|
|
92 clip_text = clip_header->data;
|
|
93 clip_length = clip_header->length - 1;
|
|
94
|
3100
|
95 if (clip_text != NULL && is_type_set == FALSE)
|
2896
|
96 type = MAUTO;
|
7
|
97 }
|
|
98
|
3100
|
99 if ((clip_text != NULL) && (clip_length > 0))
|
7
|
100 {
|
3100
|
101 clip_yank_selection(type, clip_text, clip_length, cbd);
|
7
|
102 }
|
|
103
|
3100
|
104 PhClipboardPasteFinish(cbdata);
|
7
|
105 }
|
|
106 }
|
|
107
|
|
108 void
|
3100
|
109 clip_mch_set_selection(VimClipboard *cbd)
|
7
|
110 {
|
|
111 int type;
|
|
112 long_u len;
|
|
113 char_u *text_clip, vim_clip[2], *str = NULL;
|
|
114 PhClipHeader clip_header[2];
|
|
115
|
|
116 /* Prevent recursion from clip_get_selection() */
|
3100
|
117 if (cbd->owned == TRUE)
|
7
|
118 return;
|
|
119
|
|
120 cbd->owned = TRUE;
|
3100
|
121 clip_get_selection(cbd);
|
7
|
122 cbd->owned = FALSE;
|
|
123
|
3100
|
124 type = clip_convert_selection(&str, &len, cbd);
|
|
125 if (type >= 0)
|
7
|
126 {
|
3100
|
127 text_clip = lalloc(len + 1, TRUE); /* Normal text */
|
7
|
128
|
3100
|
129 if (text_clip && vim_clip)
|
7
|
130 {
|
3100
|
131 memset(clip_header, 0, sizeof(clip_header));
|
7
|
132
|
3100
|
133 STRNCPY(clip_header[0].type, CLIP_TYPE_VIM, 8);
|
|
134 clip_header[0].length = sizeof(vim_clip);
|
7
|
135 clip_header[0].data = vim_clip;
|
|
136
|
3100
|
137 STRNCPY(clip_header[1].type, CLIP_TYPE_TEXT, 8);
|
7
|
138 clip_header[1].length = len + 1;
|
|
139 clip_header[1].data = text_clip;
|
|
140
|
3100
|
141 switch(type)
|
7
|
142 {
|
|
143 default: /* fallthrough to MLINE */
|
|
144 case MLINE: *vim_clip = 'L'; break;
|
|
145 case MCHAR: *vim_clip = 'C'; break;
|
|
146 #ifdef FEAT_VISUAL
|
|
147 case MBLOCK: *vim_clip = 'B'; break;
|
|
148 #endif
|
|
149 }
|
|
150
|
3100
|
151 vim_strncpy(text_clip, str, len);
|
7
|
152
|
|
153 vim_clip[ 1 ] = NUL;
|
|
154
|
3100
|
155 PhClipboardCopy(PhInputGroup(NULL), 2, clip_header);
|
7
|
156 }
|
3100
|
157 vim_free(text_clip);
|
7
|
158 }
|
3100
|
159 vim_free(str);
|
7
|
160 }
|
|
161 #endif
|