comparison src/quickfix.c @ 11757:74abb6c84984 v8.0.0761

patch 8.0.0761: options not set properly for a terminal buffer commit https://github.com/vim/vim/commit/1f2903c43109b16594d141a730659317b15f388d Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 23 19:51:01 2017 +0200 patch 8.0.0761: options not set properly for a terminal buffer Problem: Options of a buffer for a terminal window are not set properly. Solution: Add "terminal" value for 'buftype'. Make 'buftype' and 'bufhidden' not depend on the quickfix feature. Also set the buffer name and show "running" or "finished" in the window title.
author Christian Brabandt <cb@256bit.org>
date Sun, 23 Jul 2017 20:00:05 +0200
parents c43118ecb0a3
children 77bf0346687e
comparison
equal deleted inserted replaced
11756:e3e89d6460d0 11757:74abb6c84984
2167 { 2167 {
2168 /* Find a window using the same location list that is not a 2168 /* Find a window using the same location list that is not a
2169 * quickfix window. */ 2169 * quickfix window. */
2170 FOR_ALL_WINDOWS(usable_win_ptr) 2170 FOR_ALL_WINDOWS(usable_win_ptr)
2171 if (usable_win_ptr->w_llist == ll_ref 2171 if (usable_win_ptr->w_llist == ll_ref
2172 && usable_win_ptr->w_buffer->b_p_bt[0] != 'q') 2172 && !bt_quickfix(usable_win_ptr->w_buffer))
2173 { 2173 {
2174 usable_win = 1; 2174 usable_win = 1;
2175 break; 2175 break;
2176 } 2176 }
2177 } 2177 }
3446 /* Restore KeyTyped, setting 'filetype' may reset it. */ 3446 /* Restore KeyTyped, setting 'filetype' may reset it. */
3447 KeyTyped = old_KeyTyped; 3447 KeyTyped = old_KeyTyped;
3448 } 3448 }
3449 3449
3450 #endif /* FEAT_WINDOWS */ 3450 #endif /* FEAT_WINDOWS */
3451
3452 /*
3453 * Return TRUE if "buf" is the quickfix buffer.
3454 */
3455 int
3456 bt_quickfix(buf_T *buf)
3457 {
3458 return buf != NULL && buf->b_p_bt[0] == 'q';
3459 }
3460
3461 /*
3462 * Return TRUE if "buf" is a "nofile" or "acwrite" buffer.
3463 * This means the buffer name is not a file name.
3464 */
3465 int
3466 bt_nofile(buf_T *buf)
3467 {
3468 return buf != NULL && ((buf->b_p_bt[0] == 'n' && buf->b_p_bt[2] == 'f')
3469 || buf->b_p_bt[0] == 'a');
3470 }
3471
3472 /*
3473 * Return TRUE if "buf" is a "nowrite" or "nofile" buffer.
3474 */
3475 int
3476 bt_dontwrite(buf_T *buf)
3477 {
3478 return buf != NULL && buf->b_p_bt[0] == 'n';
3479 }
3480
3481 int
3482 bt_dontwrite_msg(buf_T *buf)
3483 {
3484 if (bt_dontwrite(buf))
3485 {
3486 EMSG(_("E382: Cannot write, 'buftype' option is set"));
3487 return TRUE;
3488 }
3489 return FALSE;
3490 }
3491
3492 /*
3493 * Return TRUE if the buffer should be hidden, according to 'hidden', ":hide"
3494 * and 'bufhidden'.
3495 */
3496 int
3497 buf_hide(buf_T *buf)
3498 {
3499 /* 'bufhidden' overrules 'hidden' and ":hide", check it first */
3500 switch (buf->b_p_bh[0])
3501 {
3502 case 'u': /* "unload" */
3503 case 'w': /* "wipe" */
3504 case 'd': return FALSE; /* "delete" */
3505 case 'h': return TRUE; /* "hide" */
3506 }
3507 return (p_hid || cmdmod.hide);
3508 }
3509 3451
3510 /* 3452 /*
3511 * Return TRUE when using ":vimgrep" for ":grep". 3453 * Return TRUE when using ":vimgrep" for ":grep".
3512 */ 3454 */
3513 int 3455 int
5582 curwin->w_llist = qi; 5524 curwin->w_llist = qi;
5583 } 5525 }
5584 } 5526 }
5585 5527
5586 #endif /* FEAT_QUICKFIX */ 5528 #endif /* FEAT_QUICKFIX */
5529
5530 /*
5531 * Return TRUE if "buf" is the quickfix buffer.
5532 */
5533 int
5534 bt_quickfix(buf_T *buf)
5535 {
5536 return buf != NULL && buf->b_p_bt[0] == 'q';
5537 }
5538
5539 /*
5540 * Return TRUE if "buf" is a terminal buffer.
5541 */
5542 int
5543 bt_terminal(buf_T *buf)
5544 {
5545 return buf != NULL && buf->b_p_bt[0] == 't';
5546 }
5547
5548 /*
5549 * Return TRUE if "buf" is a "nofile", "acwrite" or "terminal" buffer.
5550 * This means the buffer name is not a file name.
5551 */
5552 int
5553 bt_nofile(buf_T *buf)
5554 {
5555 return buf != NULL && ((buf->b_p_bt[0] == 'n' && buf->b_p_bt[2] == 'f')
5556 || buf->b_p_bt[0] == 'a'
5557 || buf->b_p_bt[0] == 't');
5558 }
5559
5560 /*
5561 * Return TRUE if "buf" is a "nowrite", "nofile" or "terminal" buffer.
5562 */
5563 int
5564 bt_dontwrite(buf_T *buf)
5565 {
5566 return buf != NULL && (buf->b_p_bt[0] == 'n' || buf->b_p_bt[0] == 't');
5567 }
5568
5569 int
5570 bt_dontwrite_msg(buf_T *buf)
5571 {
5572 if (bt_dontwrite(buf))
5573 {
5574 EMSG(_("E382: Cannot write, 'buftype' option is set"));
5575 return TRUE;
5576 }
5577 return FALSE;
5578 }
5579
5580 /*
5581 * Return TRUE if the buffer should be hidden, according to 'hidden', ":hide"
5582 * and 'bufhidden'.
5583 */
5584 int
5585 buf_hide(buf_T *buf)
5586 {
5587 /* 'bufhidden' overrules 'hidden' and ":hide", check it first */
5588 switch (buf->b_p_bh[0])
5589 {
5590 case 'u': /* "unload" */
5591 case 'w': /* "wipe" */
5592 case 'd': return FALSE; /* "delete" */
5593 case 'h': return TRUE; /* "hide" */
5594 }
5595 return (p_hid || cmdmod.hide);
5596 }
5597