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
|
|
27 memset( &parms, 0, sizeof( parms ) );
|
|
28 parms.flags = Ph_DYNAMIC_BUFFER;
|
|
29
|
|
30 is_photon_available = (PhAttach( NULL, &parms ) != NULL) ? TRUE : FALSE;
|
|
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 {
|
|
42 if( is_photon_available == TRUE && !gui.in_use)
|
|
43 clip_init( TRUE );
|
|
44 }
|
|
45
|
|
46 /*****************************************************************************/
|
|
47 /* Clipboard */
|
|
48
|
|
49 /* No support for owning the clipboard */
|
|
50 int
|
|
51 clip_mch_own_selection( VimClipboard *cbd )
|
|
52 {
|
|
53 return FALSE;
|
|
54 }
|
|
55
|
|
56 void
|
|
57 clip_mch_lose_selection( VimClipboard *cbd )
|
|
58 {
|
|
59 }
|
|
60
|
|
61 void
|
|
62 clip_mch_request_selection( VimClipboard *cbd )
|
|
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
|
|
69 cbdata = PhClipboardPasteStart( PhInputGroup( NULL ));
|
|
70 if( cbdata != NULL )
|
|
71 {
|
|
72 /* Look for the vim specific clip first */
|
|
73 clip_header = PhClipboardPasteType( cbdata, CLIP_TYPE_VIM );
|
|
74 if( clip_header != NULL && clip_header->data != NULL )
|
|
75 {
|
|
76 switch( *(char *) clip_header->data )
|
|
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 */
|
|
89 clip_header = PhClipboardPasteType( cbdata, CLIP_TYPE_TEXT );
|
|
90 if( clip_header != NULL )
|
|
91 {
|
|
92 clip_text = clip_header->data;
|
|
93 clip_length = clip_header->length - 1;
|
|
94
|
|
95 if( clip_text != NULL && is_type_set == FALSE )
|
|
96 type = (strchr( clip_text, '\r' ) != NULL) ? MLINE : MCHAR;
|
|
97 }
|
|
98
|
|
99 if( (clip_text != NULL) && (clip_length > 0) )
|
|
100 {
|
|
101 clip_yank_selection( type, clip_text, clip_length, cbd );
|
|
102 }
|
|
103
|
|
104 PhClipboardPasteFinish( cbdata );
|
|
105 }
|
|
106 }
|
|
107
|
|
108 void
|
|
109 clip_mch_set_selection( VimClipboard *cbd )
|
|
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() */
|
|
117 if( cbd->owned == TRUE )
|
|
118 return;
|
|
119
|
|
120 cbd->owned = TRUE;
|
|
121 clip_get_selection( cbd );
|
|
122 cbd->owned = FALSE;
|
|
123
|
|
124 type = clip_convert_selection( &str, &len, cbd );
|
|
125 if( type >= 0 )
|
|
126 {
|
|
127 text_clip = lalloc( len + 1, TRUE ); /* Normal text */
|
|
128
|
|
129 if( text_clip && vim_clip )
|
|
130 {
|
|
131 memset( clip_header, 0, sizeof( clip_header ) );
|
|
132
|
|
133 STRNCPY( clip_header[0].type, CLIP_TYPE_VIM, 8 );
|
|
134 clip_header[0].length = sizeof( vim_clip );
|
|
135 clip_header[0].data = vim_clip;
|
|
136
|
|
137 STRNCPY( clip_header[1].type, CLIP_TYPE_TEXT, 8 );
|
|
138 clip_header[1].length = len + 1;
|
|
139 clip_header[1].data = text_clip;
|
|
140
|
|
141 switch( type )
|
|
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
|
419
|
151 vim_strncpy( text_clip, str, len );
|
7
|
152
|
|
153 vim_clip[ 1 ] = NUL;
|
|
154
|
|
155 PhClipboardCopy( PhInputGroup( NULL ), 2, clip_header);
|
|
156 }
|
|
157 vim_free( text_clip );
|
|
158 }
|
|
159 vim_free( str );
|
|
160 }
|
|
161 #endif
|