comparison src/terminal.c @ 11876:3704ca24c9a2 v8.0.0818

patch 8.0.0818: cannot get the cursor position of a terminal commit https://github.com/vim/vim/commit/97870002d30a9846374d1ff7d73fbef351046f20 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 30 18:28:38 2017 +0200 patch 8.0.0818: cannot get the cursor position of a terminal Problem: Cannot get the cursor position of a terminal. Solution: Add term_getcursor().
author Christian Brabandt <cb@256bit.org>
date Sun, 30 Jul 2017 18:30:05 +0200
parents d444e087b8fd
children a83b19a8d7e4
comparison
equal deleted inserted replaced
11875:6b4752527e9e 11876:3704ca24c9a2
51 * job finishes). 51 * job finishes).
52 * - add option values to the command: 52 * - add option values to the command:
53 * :term <24x80> <close> vim notes.txt 53 * :term <24x80> <close> vim notes.txt
54 * - To set BS correctly, check get_stty(); Pass the fd of the pty. 54 * - To set BS correctly, check get_stty(); Pass the fd of the pty.
55 * - do not store terminal window in viminfo. Or prefix term:// ? 55 * - do not store terminal window in viminfo. Or prefix term:// ?
56 * - add term_getcursor() - return cursor position: [row, col, visible]
57 * - add a character in :ls output 56 * - add a character in :ls output
58 * - add 't' to mode() 57 * - add 't' to mode()
59 * - when closing window and job has not ended, make terminal hidden? 58 * - when closing window and job has not ended, make terminal hidden?
60 * - when closing window and job has ended, make buffer hidden? 59 * - when closing window and job has ended, make buffer hidden?
61 * - don't allow exiting Vim when a terminal is still running a job 60 * - don't allow exiting Vim when a terminal is still running a job
1635 } 1634 }
1636 return abort; 1635 return abort;
1637 } 1636 }
1638 1637
1639 /* 1638 /*
1639 * Get the buffer from the first argument in "argvars".
1640 * Returns NULL when the buffer is not for a terminal window.
1641 */
1642 static buf_T *
1643 term_get_buf(typval_T *argvars)
1644 {
1645 buf_T *buf;
1646
1647 (void)get_tv_number(&argvars[0]); /* issue errmsg if type error */
1648 ++emsg_off;
1649 buf = get_buf_tv(&argvars[0], FALSE);
1650 --emsg_off;
1651 if (buf == NULL || buf->b_term == NULL)
1652 return NULL;
1653 return buf;
1654 }
1655
1656 /*
1640 * "term_getattr(attr, name)" function 1657 * "term_getattr(attr, name)" function
1641 */ 1658 */
1642 void 1659 void
1643 f_term_getattr(typval_T *argvars, typval_T *rettv) 1660 f_term_getattr(typval_T *argvars, typval_T *rettv)
1644 { 1661 {
1669 break; 1686 break;
1670 } 1687 }
1671 } 1688 }
1672 1689
1673 /* 1690 /*
1674 * Get the buffer from the first argument in "argvars". 1691 * "term_getcursor(buf)" function
1675 * Returns NULL when the buffer is not for a terminal window. 1692 */
1676 */ 1693 void
1677 static buf_T * 1694 f_term_getcursor(typval_T *argvars, typval_T *rettv)
1678 term_get_buf(typval_T *argvars) 1695 {
1679 { 1696 buf_T *buf = term_get_buf(argvars);
1680 buf_T *buf; 1697 list_T *l;
1681 1698
1682 (void)get_tv_number(&argvars[0]); /* issue errmsg if type error */ 1699 if (rettv_list_alloc(rettv) == FAIL)
1683 ++emsg_off; 1700 return;
1684 buf = get_buf_tv(&argvars[0], FALSE); 1701 if (buf == NULL)
1685 --emsg_off; 1702 return;
1686 if (buf == NULL || buf->b_term == NULL) 1703
1687 return NULL; 1704 l = rettv->vval.v_list;
1688 return buf; 1705 list_append_number(l, buf->b_term->tl_cursor_pos.row);
1706 list_append_number(l, buf->b_term->tl_cursor_pos.col);
1707 list_append_number(l, buf->b_term->tl_cursor_visible);
1689 } 1708 }
1690 1709
1691 /* 1710 /*
1692 * "term_getjob(buf)" function 1711 * "term_getjob(buf)" function
1693 */ 1712 */