|
36 | 36 | * that buffer, attributes come from the scrollback buffer tl_scrollback. |
37 | 37 | * |
38 | 38 | * TODO: |
39 | | - * - Problem with statusline (Zyx, Christian) |
40 | 39 | * - Make CTRL-W "" paste register content to the job? |
41 | 40 | * - in bash mouse clicks are inserting characters. |
42 | 41 | * - mouse scroll: when over other window, scroll that window. |
43 | 42 | * - For the scrollback buffer store lines in the buffer, only attributes in |
44 | 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 | 44 | * - When the job ends: |
49 | 45 | * - Need an option or argument to drop the window+buffer right away, to be |
50 | 46 | * used for a shell or Vim. 'termfinish'; "close", "open" (open window when |
@@ -560,7 +556,7 @@ term_convert_key(term_T *term, int c, char *buf) |
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 | 561 | static int |
566 | 562 | term_job_running(term_T *term) |
@@ -1798,6 +1794,46 @@ f_term_getsize(typval_T *argvars, typval_T *rettv) |
1798 | 1794 | list_append_number(l, buf->b_term->tl_cols); |
1799 | 1795 | } |
1800 | 1796 |
|
| 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 | + |
1801 | 1837 | /* |
1802 | 1838 | * "term_list()" function |
1803 | 1839 | */ |
|
0 commit comments