Mercurial > vim
comparison src/terminal.c @ 11882:69e7379f46db v8.0.0821
patch 8.0.0821: cannot get the title and status of a terminal window
commit https://github.com/vim/vim/commit/b000e328efcf859d14454ffd241d44f6d14f300b
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jul 30 19:38:21 2017 +0200
patch 8.0.0821: cannot get the title and status of a terminal window
Problem: Cannot get the title and status of a terminal window.
Solution: Implement term_gettitle() and term_getstatus().
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 30 Jul 2017 19:45:03 +0200 |
parents | 45558e0507e8 |
children | 7928d62d29ee |
comparison
equal
deleted
inserted
replaced
11881:660b536de628 | 11882:69e7379f46db |
---|---|
34 * | 34 * |
35 * When the job ends the text is put in a buffer. Redrawing then happens from | 35 * When the job ends the text is put in a buffer. Redrawing then happens from |
36 * that buffer, attributes come from the scrollback buffer tl_scrollback. | 36 * that buffer, attributes come from the scrollback buffer tl_scrollback. |
37 * | 37 * |
38 * TODO: | 38 * TODO: |
39 * - Problem with statusline (Zyx, Christian) | |
40 * - Make CTRL-W "" paste register content to the job? | 39 * - Make CTRL-W "" paste register content to the job? |
41 * - in bash mouse clicks are inserting characters. | 40 * - in bash mouse clicks are inserting characters. |
42 * - mouse scroll: when over other window, scroll that window. | 41 * - mouse scroll: when over other window, scroll that window. |
43 * - For the scrollback buffer store lines in the buffer, only attributes in | 42 * - For the scrollback buffer store lines in the buffer, only attributes in |
44 * tl_scrollback. | 43 * tl_scrollback. |
45 * - Add term_status(): "" if not a terminal, "running" if job running, | |
46 * "finished" if finished, "running,vim" when job is running and in | |
47 * Terminal mode, "running,vim,pending" when job output is pending. | |
48 * - When the job ends: | 44 * - When the job ends: |
49 * - Need an option or argument to drop the window+buffer right away, to be | 45 * - Need an option or argument to drop the window+buffer right away, to be |
50 * used for a shell or Vim. 'termfinish'; "close", "open" (open window when | 46 * used for a shell or Vim. 'termfinish'; "close", "open" (open window when |
51 * job finishes). | 47 * job finishes). |
52 * - add option values to the command: | 48 * - add option values to the command: |
558 /* Read back the converted escape sequence. */ | 554 /* Read back the converted escape sequence. */ |
559 return (int)vterm_output_read(vterm, buf, KEY_BUF_LEN); | 555 return (int)vterm_output_read(vterm, buf, KEY_BUF_LEN); |
560 } | 556 } |
561 | 557 |
562 /* | 558 /* |
563 * Return TRUE if the job for "buf" is still running. | 559 * Return TRUE if the job for "term" is still running. |
564 */ | 560 */ |
565 static int | 561 static int |
566 term_job_running(term_T *term) | 562 term_job_running(term_T *term) |
567 { | 563 { |
568 /* Also consider the job finished when the channel is closed, to avoid a | 564 /* Also consider the job finished when the channel is closed, to avoid a |
1797 list_append_number(l, buf->b_term->tl_rows); | 1793 list_append_number(l, buf->b_term->tl_rows); |
1798 list_append_number(l, buf->b_term->tl_cols); | 1794 list_append_number(l, buf->b_term->tl_cols); |
1799 } | 1795 } |
1800 | 1796 |
1801 /* | 1797 /* |
1798 * "term_getstatus(buf)" function | |
1799 */ | |
1800 void | |
1801 f_term_getstatus(typval_T *argvars, typval_T *rettv) | |
1802 { | |
1803 buf_T *buf = term_get_buf(argvars); | |
1804 term_T *term; | |
1805 char_u val[100]; | |
1806 | |
1807 rettv->v_type = VAR_STRING; | |
1808 if (buf == NULL) | |
1809 return; | |
1810 term = buf->b_term; | |
1811 | |
1812 if (term_job_running(term)) | |
1813 STRCPY(val, "running"); | |
1814 else | |
1815 STRCPY(val, "finished"); | |
1816 if (term->tl_terminal_mode) | |
1817 STRCAT(val, ",terminal"); | |
1818 rettv->vval.v_string = vim_strsave(val); | |
1819 } | |
1820 | |
1821 /* | |
1822 * "term_gettitle(buf)" function | |
1823 */ | |
1824 void | |
1825 f_term_gettitle(typval_T *argvars, typval_T *rettv) | |
1826 { | |
1827 buf_T *buf = term_get_buf(argvars); | |
1828 | |
1829 rettv->v_type = VAR_STRING; | |
1830 if (buf == NULL) | |
1831 return; | |
1832 | |
1833 if (buf->b_term->tl_title != NULL) | |
1834 rettv->vval.v_string = vim_strsave(buf->b_term->tl_title); | |
1835 } | |
1836 | |
1837 /* | |
1802 * "term_list()" function | 1838 * "term_list()" function |
1803 */ | 1839 */ |
1804 void | 1840 void |
1805 f_term_list(typval_T *argvars UNUSED, typval_T *rettv) | 1841 f_term_list(typval_T *argvars UNUSED, typval_T *rettv) |
1806 { | 1842 { |