Mercurial > vim
comparison src/if_py_both.h @ 4407:2a166caf8709 v7.3.952
updated for version 7.3.952
Problem: Python: It's not easy to change window/buffer/tabpage.
Solution: Add ability to assign to vim.current.{tabpage,buffer,window}.
(ZyX)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Wed, 15 May 2013 15:51:08 +0200 |
parents | 907b1f035ee7 |
children | 1afdb7d21c14 |
comparison
equal
deleted
inserted
replaced
4406:5fa162c3a23c | 4407:2a166caf8709 |
---|---|
3242 if (SetBufferLine(curbuf, (PyInt)curwin->w_cursor.lnum, value, NULL) == FAIL) | 3242 if (SetBufferLine(curbuf, (PyInt)curwin->w_cursor.lnum, value, NULL) == FAIL) |
3243 return -1; | 3243 return -1; |
3244 | 3244 |
3245 return 0; | 3245 return 0; |
3246 } | 3246 } |
3247 else if (strcmp(name, "buffer") == 0) | |
3248 { | |
3249 int count; | |
3250 | |
3251 if (value->ob_type != &BufferType) | |
3252 { | |
3253 PyErr_SetString(PyExc_TypeError, _("expected vim.buffer object")); | |
3254 return -1; | |
3255 } | |
3256 | |
3257 if (CheckBuffer((BufferObject *)(value))) | |
3258 return -1; | |
3259 count = ((BufferObject *)(value))->buf->b_fnum; | |
3260 | |
3261 if (do_buffer(DOBUF_GOTO, DOBUF_FIRST, FORWARD, count, 0) == FAIL) | |
3262 { | |
3263 PyErr_SetVim(_("failed to switch to given buffer")); | |
3264 return -1; | |
3265 } | |
3266 | |
3267 return 0; | |
3268 } | |
3269 else if (strcmp(name, "window") == 0) | |
3270 { | |
3271 int count; | |
3272 | |
3273 if (value->ob_type != &WindowType) | |
3274 { | |
3275 PyErr_SetString(PyExc_TypeError, _("expected vim.window object")); | |
3276 return -1; | |
3277 } | |
3278 | |
3279 if (CheckWindow((WindowObject *)(value))) | |
3280 return -1; | |
3281 count = get_win_number(((WindowObject *)(value))->win, firstwin); | |
3282 | |
3283 if (!count) | |
3284 { | |
3285 PyErr_SetString(PyExc_ValueError, | |
3286 _("failed to find window in the current tab page")); | |
3287 return -1; | |
3288 } | |
3289 | |
3290 win_goto(((WindowObject *)(value))->win); | |
3291 if (((WindowObject *)(value))->win != curwin) | |
3292 { | |
3293 PyErr_SetString(PyExc_RuntimeError, | |
3294 _("did not switch to the specified window")); | |
3295 return -1; | |
3296 } | |
3297 | |
3298 return 0; | |
3299 } | |
3300 else if (strcmp(name, "tabpage") == 0) | |
3301 { | |
3302 if (value->ob_type != &TabPageType) | |
3303 { | |
3304 PyErr_SetString(PyExc_TypeError, _("expected vim.tabpage object")); | |
3305 return -1; | |
3306 } | |
3307 | |
3308 if (CheckTabPage((TabPageObject *)(value))) | |
3309 return -1; | |
3310 | |
3311 goto_tabpage_tp(((TabPageObject *)(value))->tab, TRUE, TRUE); | |
3312 if (((TabPageObject *)(value))->tab != curtab) | |
3313 { | |
3314 PyErr_SetString(PyExc_RuntimeError, | |
3315 _("did not switch to the specified tab page")); | |
3316 return -1; | |
3317 } | |
3318 | |
3319 return 0; | |
3320 } | |
3247 else | 3321 else |
3248 { | 3322 { |
3249 PyErr_SetString(PyExc_AttributeError, name); | 3323 PyErr_SetString(PyExc_AttributeError, name); |
3250 return -1; | 3324 return -1; |
3251 } | 3325 } |