aboutsummaryrefslogtreecommitdiffhomepage
path: root/reader.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2015-06-04 13:31:48 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2015-06-14 11:36:11 -0700
commit767742c7e7ee53c8aa7950f928d551c63d69448f (patch)
tree600a9090d1c5dd699170bf2b348e551c2f2f6287 /reader.cpp
parent0ddd0ed4fbee08429c215946ca4dd19cd3e56a63 (diff)
Rework how the mode is reported in fish_vi_mode
Add a new function fish_mode_prompt which (if it is defined) has its output prepended to the left prompt. Rather than replacing the prompt wholesale, make fish_vi_mode enable this function by setting a variable __fish_vi_mode. This enables vi mode to interoperate nicely with custom prompts. Users who want to change how the mode is reported can either redefine this function or erase it entirely. Fixes #1988.
Diffstat (limited to 'reader.cpp')
-rw-r--r--reader.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/reader.cpp b/reader.cpp
index 086a2a5f..dcf6b1c0 100644
--- a/reader.cpp
+++ b/reader.cpp
@@ -128,6 +128,10 @@ commence.
#define RIGHT_PROMPT_FUNCTION_NAME L"fish_right_prompt"
+/* The name of the function for getting the input mode indicator */
+#define MODE_PROMPT_FUNCTION_NAME L"fish_mode_prompt"
+
+
/**
The default title for the reader. This is used by reader_readline.
*/
@@ -997,6 +1001,18 @@ static void exec_prompt()
{
proc_push_interactive(0);
+ // Prepend any mode indicator to the left prompt (#1988)
+ if (function_exists(MODE_PROMPT_FUNCTION_NAME))
+ {
+ wcstring_list_t mode_indicator_list;
+ exec_subshell(MODE_PROMPT_FUNCTION_NAME, mode_indicator_list, apply_exit_status);
+ // We do not support multiple lines in the mode indicator, so just concatenate all of them
+ for (size_t i = 0; i < mode_indicator_list.size(); i++)
+ {
+ data->left_prompt_buff += mode_indicator_list.at(i);
+ }
+ }
+
if (! data->left_prompt.empty())
{
wcstring_list_t prompt_list;