annotate src/os_qnx.c @ 1249:a3362a9b6494

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