From 407abb3a6c5c1c706bf8797a1431e57e97a6b797 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 2 Apr 2017 01:00:40 +0300 Subject: eval,ex_getln: Add support for coloring input() prompts --- runtime/doc/eval.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'runtime') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 2a73590c76..2262c01374 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -4699,6 +4699,7 @@ input({opts}) cancelreturn "" Same as {cancelreturn} from |inputdialog()|. Also works with input(). + highlight nothing Highlight handler: |Funcref|. The highlighting set with |:echohl| is used for the prompt. The input is entered just like a command-line, with the same @@ -4722,6 +4723,22 @@ input({opts}) more information. Example: > let fname = input("File: ", "", "file") < + The optional highlight key allows specifying function which + will be used for highlighting. This function receives user + input as its only argument and must return a list of 3-tuples + [hl_start_byte, hl_end_byte + 1, hl_group] where + hl_start_byte is the first highlighted byte, + hl_end_byte is the last highlighted byte (+ 1!), + hl_group is |:hl| group used for highlighting. + *E5403* *E5404* *E5405* *E5406* + Both hl_start_byte and hl_end_byte + 1 must point to the start + of the multibyte character (highlighting must not break + multibyte characters), hl_end_byte + 1 may be equal to the + input length. Start column must be in range [0, len(input)), + end column must be in range (hl_start_byte, len(input)], + sections must be ordered so that next hl_start_byte is greater + then or equal to previous hl_end_byte. + NOTE: This function must not be used in a startup file, for the versions that only run in GUI mode (e.g., the Win32 GUI). Note: When input() is called from within a mapping it will -- cgit From cb3c71eac916eacc2964d824ddc23460d0e91c47 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 17 Jul 2017 02:32:32 +0300 Subject: doc: Adjust documentation a bit 2 spaces after sentense ends, clarify what will be highlighted. --- runtime/doc/eval.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index e51f0f5dfc..b45eceb97a 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -4725,9 +4725,10 @@ input({opts}) let fname = input("File: ", "", "file") < The optional highlight key allows specifying function which - will be used for highlighting. This function receives user - input as its only argument and must return a list of 3-tuples - [hl_start_byte, hl_end_byte + 1, hl_group] where + will be used for highlighting user input. This function + receives user input as its only argument and must return + a list of 3-tuples [hl_start_byte, hl_end_byte + 1, hl_group] + where hl_start_byte is the first highlighted byte, hl_end_byte is the last highlighted byte (+ 1!), hl_group is |:hl| group used for highlighting. @@ -4735,7 +4736,7 @@ input({opts}) Both hl_start_byte and hl_end_byte + 1 must point to the start of the multibyte character (highlighting must not break multibyte characters), hl_end_byte + 1 may be equal to the - input length. Start column must be in range [0, len(input)), + input length. Start column must be in range [0, len(input)), end column must be in range (hl_start_byte, len(input)], sections must be ordered so that next hl_start_byte is greater then or equal to previous hl_end_byte. -- cgit From d23c0de0c17a665cf4aff3bf4772a08453c6f1dd Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 26 Jul 2017 12:31:01 +0300 Subject: doc: Update documentation --- runtime/doc/eval.txt | 21 ++++++++++++--------- runtime/doc/vim_diff.txt | 12 +++++++++++- 2 files changed, 23 insertions(+), 10 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index b45eceb97a..3a928c97ec 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -4723,23 +4723,26 @@ input({opts}) "-complete=" argument. Refer to |:command-completion| for more information. Example: > let fname = input("File: ", "", "file") -< +< *E5400* *E5402* The optional highlight key allows specifying function which will be used for highlighting user input. This function receives user input as its only argument and must return - a list of 3-tuples [hl_start_byte, hl_end_byte + 1, hl_group] + a list of 3-tuples [hl_start_col, hl_end_col + 1, hl_group] where - hl_start_byte is the first highlighted byte, - hl_end_byte is the last highlighted byte (+ 1!), + hl_start_col is the first highlighted column, + hl_end_col is the last highlighted column (+ 1!), hl_group is |:hl| group used for highlighting. *E5403* *E5404* *E5405* *E5406* - Both hl_start_byte and hl_end_byte + 1 must point to the start + Both hl_start_col and hl_end_col + 1 must point to the start of the multibyte character (highlighting must not break - multibyte characters), hl_end_byte + 1 may be equal to the + multibyte characters), hl_end_col + 1 may be equal to the input length. Start column must be in range [0, len(input)), - end column must be in range (hl_start_byte, len(input)], - sections must be ordered so that next hl_start_byte is greater - then or equal to previous hl_end_byte. + end column must be in range (hl_start_col, len(input)], + sections must be ordered so that next hl_start_col is greater + then or equal to previous hl_end_col. + + Currently coloring is disabled when command-line contains + arabic characters. NOTE: This function must not be used in a startup file, for the versions that only run in GUI mode (e.g., the Win32 GUI). diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 5801da1132..42f273588a 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -126,7 +126,6 @@ Commands: Functions: |dictwatcheradd()| notifies a callback whenever a |Dict| is modified |dictwatcherdel()| - |execute()| works with |:redir| |msgpackdump()|, |msgpackparse()| provide msgpack de/serialization Events: @@ -143,6 +142,15 @@ Highlight groups: |hl-TermCursorNC| |hl-Whitespace| highlights 'listchars' whitespace +UI: + *E5408* *E5409* *g:Nvim_color_expr* *g:Nvim_color_cmdline* + UI now supports command-line coloring. Officially only |input()| and + |inputdialog()| may be colored, temporary for testing purposes expressions + (e.g. |i_CTRL-R_=|) and regular command-line (|:|) are colored by callbacks + defined in `g:Nvim_color_expr` and `g:Nvim_color_cmdline` respectively. + Callbacks are to be replaced by parser implemented in C which will also do + the coloring. + ============================================================================== 4. Changed features *nvim-features-changed* @@ -261,6 +269,8 @@ Lua interface (|if_lua.txt|): on cancel and completion respectively) via dictionary argument (replaces all other arguments if used). +|input()| and |inputdialog()| now support user-defined cmdline highlighting. + ============================================================================== 5. Missing legacy features *nvim-features-missing* -- cgit From f1ef94b87150bd8f1f70c670409bd668136b8258 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 14 Aug 2017 01:20:52 +0300 Subject: doc: Clarify how function is executed --- runtime/doc/eval.txt | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'runtime') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 905d0b590b..279c5e4442 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -4744,6 +4744,14 @@ input({opts}) sections must be ordered so that next hl_start_col is greater then or equal to previous hl_end_col. + Highlight function is called at least once for each new input + string, before command-line is redrawn. It is expected that + function is pure for the duration of one input() call, i.e. it + produces the same output for the same input, so output may be + memoized. Function is run like under |:silent| modifier, + additionally any errors from function cause it to be no longer + executed for the duration of the current input() call. + Currently coloring is disabled when command-line contains arabic characters. -- cgit From 5c60cd2abb74a14a99bea87e0b76e4f35a50bb07 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 14 Aug 2017 01:40:21 +0300 Subject: doc: State that it is called for new *displayed* input --- runtime/doc/eval.txt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 279c5e4442..4e8b6527eb 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -4744,13 +4744,14 @@ input({opts}) sections must be ordered so that next hl_start_col is greater then or equal to previous hl_end_col. - Highlight function is called at least once for each new input - string, before command-line is redrawn. It is expected that - function is pure for the duration of one input() call, i.e. it - produces the same output for the same input, so output may be - memoized. Function is run like under |:silent| modifier, - additionally any errors from function cause it to be no longer - executed for the duration of the current input() call. + Highlight function is called at least once for each new + displayed input string, before command-line is redrawn. It is + expected that function is pure for the duration of one input() + call, i.e. it produces the same output for the same input, so + output may be memoized. Function is run like under |:silent| + modifier, additionally any errors from function cause it to be + no longer executed for the duration of the current input() + call. Currently coloring is disabled when command-line contains arabic characters. -- cgit