Display the supplied message in the preview window
( message, modifiers )
| 1233 | |
| 1234 | |
| 1235 | def WriteToPreviewWindow( message, modifiers ): |
| 1236 | """ Display the supplied message in the preview window """ |
| 1237 | |
| 1238 | # This isn't something that comes naturally to Vim. Vim only wants to show |
| 1239 | # tags and/or actual files in the preview window, so we have to hack it a |
| 1240 | # little bit. We generate a temporary file name and "open" that, then write |
| 1241 | # the data to it. We make sure the buffer can't be edited or saved. Other |
| 1242 | # approaches include simply opening a split, but we want to take advantage of |
| 1243 | # the existing Vim options for preview window height, etc. |
| 1244 | |
| 1245 | ClosePreviewWindow() |
| 1246 | |
| 1247 | OpenFileInPreviewWindow( vim.eval( 'tempname()' ), modifiers ) |
| 1248 | |
| 1249 | if JumpToPreviewWindow(): |
| 1250 | # We actually got to the preview window. By default the preview window can't |
| 1251 | # be changed, so we make it writable, write to it, then make it read only |
| 1252 | # again. |
| 1253 | vim.current.buffer.options[ 'modifiable' ] = True |
| 1254 | vim.current.buffer.options[ 'readonly' ] = False |
| 1255 | |
| 1256 | vim.current.buffer[ : ] = message.splitlines() |
| 1257 | |
| 1258 | vim.current.buffer.options[ 'buftype' ] = 'nofile' |
| 1259 | vim.current.buffer.options[ 'bufhidden' ] = 'wipe' |
| 1260 | vim.current.buffer.options[ 'buflisted' ] = False |
| 1261 | vim.current.buffer.options[ 'swapfile' ] = False |
| 1262 | vim.current.buffer.options[ 'modifiable' ] = False |
| 1263 | vim.current.buffer.options[ 'readonly' ] = True |
| 1264 | |
| 1265 | # We need to prevent closing the window causing a warning about unsaved |
| 1266 | # file, so we pretend to Vim that the buffer has not been changed. |
| 1267 | vim.current.buffer.options[ 'modified' ] = False |
| 1268 | |
| 1269 | JumpToPreviousWindow() |
| 1270 | else: |
| 1271 | # We couldn't get to the preview window, but we still want to give the user |
| 1272 | # the information we have. The only remaining option is to echo to the |
| 1273 | # status area. |
| 1274 | PostVimMessage( message, warning = False ) |
| 1275 | |
| 1276 | |
| 1277 | def BufferIsVisibleForFilename( filename ): |
nothing calls this directly
no test coverage detected