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 case 'B': type = MBLOCK; break;
|
|
82 }
|
|
83 is_type_set = TRUE;
|
|
84 }
|
|
85
|
|
86 /* Try for just normal text */
|
3100
|
87 clip_header = PhClipboardPasteType(cbdata, CLIP_TYPE_TEXT);
|
|
88 if (clip_header != NULL)
|
7
|
89 {
|
|
90 clip_text = clip_header->data;
|
|
91 clip_length = clip_header->length - 1;
|
|
92
|
3100
|
93 if (clip_text != NULL && is_type_set == FALSE)
|
2896
|
94 type = MAUTO;
|
7
|
95 }
|
|
96
|
3100
|
97 if ((clip_text != NULL) && (clip_length > 0))
|
7
|
98 {
|
3100
|
99 clip_yank_selection(type, clip_text, clip_length, cbd);
|
7
|
100 }
|
|
101
|
3100
|
102 PhClipboardPasteFinish(cbdata);
|
7
|
103 }
|
|
104 }
|
|
105
|
|
106 void
|
3100
|
107 clip_mch_set_selection(VimClipboard *cbd)
|
7
|
108 {
|
|
109 int type;
|
|
110 long_u len;
|
|
111 char_u *text_clip, vim_clip[2], *str = NULL;
|
|
112 PhClipHeader clip_header[2];
|
|
113
|
|
114 /* Prevent recursion from clip_get_selection() */
|
3100
|
115 if (cbd->owned == TRUE)
|
7
|
116 return;
|
|
117
|
|
118 cbd->owned = TRUE;
|
3100
|
119 clip_get_selection(cbd);
|
7
|
120 cbd->owned = FALSE;
|
|
121
|
3100
|
122 type = clip_convert_selection(&str, &len, cbd);
|
|
123 if (type >= 0)
|
7
|
124 {
|
3100
|
125 text_clip = lalloc(len + 1, TRUE); /* Normal text */
|
7
|
126
|
3100
|
127 if (text_clip && vim_clip)
|
7
|
128 {
|
3100
|
129 memset(clip_header, 0, sizeof(clip_header));
|
7
|
130
|
3100
|
131 STRNCPY(clip_header[0].type, CLIP_TYPE_VIM, 8);
|
|
132 clip_header[0].length = sizeof(vim_clip);
|
7
|
133 clip_header[0].data = vim_clip;
|
|
134
|
3100
|
135 STRNCPY(clip_header[1].type, CLIP_TYPE_TEXT, 8);
|
7
|
136 clip_header[1].length = len + 1;
|
|
137 clip_header[1].data = text_clip;
|
|
138
|
3100
|
139 switch(type)
|
7
|
140 {
|
|
141 default: /* fallthrough to MLINE */
|
|
142 case MLINE: *vim_clip = 'L'; break;
|
|
143 case MCHAR: *vim_clip = 'C'; break;
|
|
144 case MBLOCK: *vim_clip = 'B'; break;
|
|
145 }
|
|
146
|
3100
|
147 vim_strncpy(text_clip, str, len);
|
7
|
148
|
|
149 vim_clip[ 1 ] = NUL;
|
|
150
|
3100
|
151 PhClipboardCopy(PhInputGroup(NULL), 2, clip_header);
|
7
|
152 }
|
3100
|
153 vim_free(text_clip);
|
7
|
154 }
|
3100
|
155 vim_free(str);
|
7
|
156 }
|
|
157 #endif
|