Mercurial > vim
annotate src/os_qnx.c @ 32798:f48e27f20e6b v9.0.1715
patch 9.0.1715: duplicate test in message_test.c
Commit: https://github.com/vim/vim/commit/7772c93a3ec1ce60469e9aea9899687ae1141f34
Author: zeertzjq <zeertzjq@outlook.com>
Date: Tue Aug 15 22:48:40 2023 +0200
patch 9.0.1715: duplicate test in message_test.c
Problem: duplicate test in message_test.c
Solution: Remove duplicate test and make functions static
closes: #12803
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 15 Aug 2023 23:00:04 +0200 |
parents | 97255d909654 |
children |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
7833
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 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 | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
5735
diff
changeset
|
22 void qnx_init(void) |
7 | 23 { |
24 #if defined(FEAT_GUI_PHOTON) | |
25 PhChannelParms_t parms; | |
26 | |
32120
97255d909654
patch 9.0.1391: "clear" macros are not always used
Bram Moolenaar <Bram@vim.org>
parents:
31752
diff
changeset
|
27 CLEAR_FIELD(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 | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17063
diff
changeset
|
39 // Turn on the clipboard for a console vim when photon is running |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
5735
diff
changeset
|
40 void qnx_clip_init(void) |
7 | 41 { |
3100 | 42 if (is_photon_available == TRUE && !gui.in_use) |
43 clip_init(TRUE); | |
7 | 44 } |
45 | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17063
diff
changeset
|
46 ///////////////////////////////////////////////////////////////////////////// |
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17063
diff
changeset
|
47 // Clipboard |
7 | 48 |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17063
diff
changeset
|
49 // No support for owning the clipboard |
7 | 50 int |
17063
3147c7c2e86b
patch 8.1.1531: clipboard type name is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
51 clip_mch_own_selection(Clipboard_T *cbd) |
7 | 52 { |
53 return FALSE; | |
54 } | |
55 | |
56 void | |
17063
3147c7c2e86b
patch 8.1.1531: clipboard type name is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
57 clip_mch_lose_selection(Clipboard_T *cbd) |
7 | 58 { |
59 } | |
60 | |
61 void | |
17063
3147c7c2e86b
patch 8.1.1531: clipboard type name is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
62 clip_mch_request_selection(Clipboard_T *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)); |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18810
diff
changeset
|
70 if (cbdata == NULL) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18810
diff
changeset
|
71 return; |
7 | 72 |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18810
diff
changeset
|
73 // Look for the vim specific clip first |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18810
diff
changeset
|
74 clip_header = PhClipboardPasteType(cbdata, CLIP_TYPE_VIM); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18810
diff
changeset
|
75 if (clip_header != NULL && clip_header->data != NULL) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18810
diff
changeset
|
76 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18810
diff
changeset
|
77 switch(*(char *) clip_header->data) |
7 | 78 { |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18810
diff
changeset
|
79 default: // fallthrough to line type |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18810
diff
changeset
|
80 case 'L': type = MLINE; break; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18810
diff
changeset
|
81 case 'C': type = MCHAR; break; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18810
diff
changeset
|
82 case 'B': type = MBLOCK; break; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18810
diff
changeset
|
83 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18810
diff
changeset
|
84 is_type_set = TRUE; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18810
diff
changeset
|
85 } |
7 | 86 |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18810
diff
changeset
|
87 // Try for just normal text |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18810
diff
changeset
|
88 clip_header = PhClipboardPasteType(cbdata, CLIP_TYPE_TEXT); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18810
diff
changeset
|
89 if (clip_header != NULL) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18810
diff
changeset
|
90 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18810
diff
changeset
|
91 clip_text = clip_header->data; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18810
diff
changeset
|
92 clip_length = clip_header->length - 1; |
7 | 93 |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18810
diff
changeset
|
94 if (clip_text != NULL && is_type_set == FALSE) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18810
diff
changeset
|
95 type = MAUTO; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18810
diff
changeset
|
96 } |
7 | 97 |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18810
diff
changeset
|
98 if ((clip_text != NULL) && (clip_length > 0)) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18810
diff
changeset
|
99 clip_yank_selection(type, clip_text, clip_length, cbd); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18810
diff
changeset
|
100 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18810
diff
changeset
|
101 PhClipboardPasteFinish(cbdata); |
7 | 102 } |
103 | |
104 void | |
17063
3147c7c2e86b
patch 8.1.1531: clipboard type name is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
105 clip_mch_set_selection(Clipboard_T *cbd) |
7 | 106 { |
107 int type; | |
108 long_u len; | |
109 char_u *text_clip, vim_clip[2], *str = NULL; | |
110 PhClipHeader clip_header[2]; | |
111 | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17063
diff
changeset
|
112 // Prevent recursion from clip_get_selection() |
3100 | 113 if (cbd->owned == TRUE) |
7 | 114 return; |
115 | |
116 cbd->owned = TRUE; | |
3100 | 117 clip_get_selection(cbd); |
7 | 118 cbd->owned = FALSE; |
119 | |
3100 | 120 type = clip_convert_selection(&str, &len, cbd); |
121 if (type >= 0) | |
7 | 122 { |
16768
695d9ef00b03
patch 8.1.1386: unessesary type casts for lalloc()
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
123 text_clip = alloc(len + 1); // Normal text |
7 | 124 |
3100 | 125 if (text_clip && vim_clip) |
7 | 126 { |
32120
97255d909654
patch 9.0.1391: "clear" macros are not always used
Bram Moolenaar <Bram@vim.org>
parents:
31752
diff
changeset
|
127 CLEAR_FIELD(clip_header); |
7 | 128 |
3100 | 129 STRNCPY(clip_header[0].type, CLIP_TYPE_VIM, 8); |
130 clip_header[0].length = sizeof(vim_clip); | |
7 | 131 clip_header[0].data = vim_clip; |
132 | |
3100 | 133 STRNCPY(clip_header[1].type, CLIP_TYPE_TEXT, 8); |
7 | 134 clip_header[1].length = len + 1; |
135 clip_header[1].data = text_clip; | |
136 | |
3100 | 137 switch(type) |
7 | 138 { |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17063
diff
changeset
|
139 default: // fallthrough to MLINE |
7 | 140 case MLINE: *vim_clip = 'L'; break; |
141 case MCHAR: *vim_clip = 'C'; break; | |
142 case MBLOCK: *vim_clip = 'B'; break; | |
143 } | |
144 | |
3100 | 145 vim_strncpy(text_clip, str, len); |
7 | 146 |
147 vim_clip[ 1 ] = NUL; | |
148 | |
3100 | 149 PhClipboardCopy(PhInputGroup(NULL), 2, clip_header); |
7 | 150 } |
3100 | 151 vim_free(text_clip); |
7 | 152 } |
3100 | 153 vim_free(str); |
7 | 154 } |
155 #endif |