Mercurial > vim
comparison src/channel.c @ 14019:dc67449d648c v8.1.0027
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
commit https://github.com/vim/vim/commit/f273245f6433d5d43a5671306b520a3230c35787
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jun 3 14:47:35 2018 +0200
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Problem: Difficult to make a plugin that feeds a line to a job.
Solution: Add the nitial code for the "prompt" buftype.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 03 Jun 2018 15:00:07 +0200 |
parents | 8314bb913e14 |
children | e271ca6f32f9 |
comparison
equal
deleted
inserted
replaced
14018:c3064aaf53fb | 14019:dc67449d648c |
---|---|
5834 /* We don't try freeing the job, obviously the caller still has a | 5834 /* We don't try freeing the job, obviously the caller still has a |
5835 * reference to it. */ | 5835 * reference to it. */ |
5836 return 1; | 5836 return 1; |
5837 } | 5837 } |
5838 | 5838 |
5839 void | |
5840 invoke_prompt_callback(void) | |
5841 { | |
5842 typval_T rettv; | |
5843 int dummy; | |
5844 typval_T argv[2]; | |
5845 char_u *text; | |
5846 char_u *prompt; | |
5847 linenr_T lnum = curbuf->b_ml.ml_line_count; | |
5848 | |
5849 // Add a new line for the prompt before invoking the callback, so that | |
5850 // text can always be inserted above the last line. | |
5851 ml_append(lnum, (char_u *)"", 0, FALSE); | |
5852 curwin->w_cursor.lnum = lnum + 1; | |
5853 curwin->w_cursor.col = 0; | |
5854 | |
5855 if (curbuf->b_prompt_callback == NULL) | |
5856 return; | |
5857 text = ml_get(lnum); | |
5858 prompt = prompt_text(); | |
5859 if (STRLEN(text) >= STRLEN(prompt)) | |
5860 text += STRLEN(prompt); | |
5861 argv[0].v_type = VAR_STRING; | |
5862 argv[0].vval.v_string = vim_strsave(text); | |
5863 argv[1].v_type = VAR_UNKNOWN; | |
5864 | |
5865 call_func(curbuf->b_prompt_callback, | |
5866 (int)STRLEN(curbuf->b_prompt_callback), | |
5867 &rettv, 1, argv, NULL, 0L, 0L, &dummy, TRUE, | |
5868 curbuf->b_prompt_partial, NULL); | |
5869 clear_tv(&argv[0]); | |
5870 clear_tv(&rettv); | |
5871 } | |
5872 | |
5839 #endif /* FEAT_JOB_CHANNEL */ | 5873 #endif /* FEAT_JOB_CHANNEL */ |