Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:26
erlang
2301-stdlib-add-shell-multiline_prompt_func-1.p...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 2301-stdlib-add-shell-multiline_prompt_func-1.patch of Package erlang
From 73cd01c77df3d33ae5eaf53febd272a2424ac570 Mon Sep 17 00:00:00 2001 From: frazze-jobb <frazze@erlang.org> Date: Thu, 2 Nov 2023 14:50:01 +0100 Subject: [PATCH] stdlib: add shell:multiline_prompt_func/1 updates stdlib and kernel dependencies --- lib/kernel/src/kernel.app.src | 2 +- lib/kernel/test/interactive_shell_SUITE.erl | 11 +++++++++- lib/stdlib/doc/src/shell.xml | 23 ++++++++++++++++----- lib/stdlib/doc/src/stdlib_app.xml | 10 +++++++++ lib/stdlib/src/shell.erl | 9 +++++++- lib/stdlib/src/stdlib.app.src | 2 +- 6 files changed, 48 insertions(+), 9 deletions(-) diff --git a/lib/kernel/src/kernel.app.src b/lib/kernel/src/kernel.app.src index a06840ac1c..e871fbb2cc 100644 --- a/lib/kernel/src/kernel.app.src +++ b/lib/kernel/src/kernel.app.src @@ -162,7 +162,7 @@ {shell_history_drop,[]} ]}, {mod, {kernel, []}}, - {runtime_dependencies, ["erts-14.0", "stdlib-5.0", + {runtime_dependencies, ["erts-14.0", "stdlib-6.0", "sasl-3.0", "crypto-5.0"]} ] }. diff --git a/lib/kernel/test/interactive_shell_SUITE.erl b/lib/kernel/test/interactive_shell_SUITE.erl index 39834cbce4..b15216317e 100644 --- a/lib/kernel/test/interactive_shell_SUITE.erl +++ b/lib/kernel/test/interactive_shell_SUITE.erl @@ -481,7 +481,7 @@ shell_multiline_prompt(Config) -> Term1 = start_tty([{args,["-stdlib","shell_multiline_prompt","{shell,inverted_space_prompt}"]}|Config]), Term2 = start_tty([{args,["-stdlib","shell_multiline_prompt","\"...> \""]}|Config]), Term3 = start_tty([{args,["-stdlib","shell_multiline_prompt","edlin"]}|Config]), - + Term4 = start_tty(Config), try check_location(Term1, {0, 0}), send_tty(Term1,"\na"), @@ -507,6 +507,15 @@ shell_multiline_prompt(Config) -> ok after stop_tty(Term3) + end, + try + send_tty(Term4, "shell:multiline_prompt_func(\"-> \").\n"), + check_content(Term4, "default"), + send_tty(Term4, "a\nb"), + check_content(Term4, "-> b"), + ok + after + stop_tty(Term4) end. shell_clear(Config) -> diff --git a/lib/stdlib/doc/src/shell.xml b/lib/stdlib/doc/src/shell.xml index a6bba8dcb4..3de6f34680 100644 --- a/lib/stdlib/doc/src/shell.xml +++ b/lib/stdlib/doc/src/shell.xml @@ -898,7 +898,10 @@ q - quit erlang function by calling <seemfa marker="#prompt_func/1"> <c>prompt_func/1</c></seemfa> or by setting application configuration parameter <c>shell_prompt_func</c> for the - STDLIB application.</p> + STDLIB application. Similarly the multiline prompt can + be configured as well, by calling <seemfa marker="#multiline_prompt_func/1"> + <c>multiline_prompt_func/1</c></seemfa> or by setting the application + parameter <c>shell_multiline_prompt</c> for the STDLIB application.</p> <p>A customized prompt function is stated as a tuple <c>{Mod, Func}</c>. The function is called as @@ -952,7 +955,8 @@ q - quit erlang <desc> <p>Configures the multiline prompt as inverted space. It may be set explicitly as - <c>-stdlib shell_multiline_prompt {shell, inverted_space_prompt}</c>.</p> + <c>-stdlib shell_multiline_prompt {shell, inverted_space_prompt}</c> + or calling <c>multiline_prompt_func({shell, inverted_space_prompt}).</c></p> </desc> </func> @@ -971,7 +975,16 @@ q - quit erlang </func> <func> - <name name="prompt_width" arity="1" since="OTP 27.0"/> + <name name="multiline_prompt_func" arity="1" since="OTP 27.0"/> + <fsummary>Set the shell multiline prompt.</fsummary> + <desc> + <p>Sets the shell multiline prompt function to <c><anno>PromptFunc</anno></c>. + The previous prompt function is returned.</p> + </desc> + </func> + + <func> + <name name="prompt_width" arity="1" since="OTP 27.0"/> <fsummary>Computes the width of a prompt.</fsummary> <desc> <p>It receives a prompt and computes its width, diff --git a/lib/stdlib/doc/src/stdlib_app.xml b/lib/stdlib/doc/src/stdlib_app.xml index e12bc8b17f..6d455d0949 100644 --- a/lib/stdlib/doc/src/stdlib_app.xml +++ b/lib/stdlib/doc/src/stdlib_app.xml @@ -80,6 +80,16 @@ </list> <p>Can be used to set a customized Erlang shell prompt function.</p> </item> + <tag><marker id="shell_multiline_prompt"/><c>shell_multiline_prompt = {Mod, Func} | string() | default</c></tag> + <item> + <p>where</p> + <list type="bulleted"> + <item><c>Mod = atom()</c></item> + <item><c>Func = atom()</c></item> + </list> + <p>Can be used to set a customized multiline shell prompt function. The multiline prompt function + takes the main prompt as its only parameter.</p> + </item> <tag><marker id="shell_saved_results"/><c>shell_saved_results = integer() >= 0</c></tag> <item> <p>Can be used to determine how many results are saved by the Erlang diff --git a/lib/stdlib/src/shell.erl b/lib/stdlib/src/shell.erl index 2e174b499b..760889164c 100644 --- a/lib/stdlib/src/shell.erl +++ b/lib/stdlib/src/shell.erl @@ -23,7 +23,7 @@ -export([get_state/0, get_function/2]). -export([start_restricted/1, stop_restricted/0]). -export([local_func/0, local_func/1, local_allowed/3, non_local_allowed/3]). --export([catch_exception/1, prompt_func/1, strings/1]). +-export([catch_exception/1, prompt_func/1, multiline_prompt_func/1, strings/1]). -export([start_interactive/0, start_interactive/1]). -export([read_and_add_records/5]). -export([default_multiline_prompt/1, inverted_space_prompt/1]). @@ -1697,6 +1697,13 @@ catch_exception(Bool) -> prompt_func(PromptFunc) -> set_env(stdlib, shell_prompt_func, PromptFunc, ?DEF_PROMPT_FUNC). +-spec multiline_prompt_func(PromptFunc) -> PromptFunc2 when + PromptFunc :: 'default' | {module(),function()} | string(), + PromptFunc2 :: 'default' | {module(),function()} | string(). + +multiline_prompt_func(PromptFunc) -> + set_env(stdlib, shell_multiline_prompt, PromptFunc, ?DEF_PROMPT_FUNC). + -spec strings(Strings) -> Strings2 when Strings :: boolean(), Strings2 :: boolean(). diff --git a/lib/stdlib/src/stdlib.app.src b/lib/stdlib/src/stdlib.app.src index 932d05e895..1894a2cb2c 100644 --- a/lib/stdlib/src/stdlib.app.src +++ b/lib/stdlib/src/stdlib.app.src @@ -116,6 +116,6 @@ dets]}, {applications, [kernel]}, {env, []}, - {runtime_dependencies, ["sasl-3.0","kernel-9.0","erts-13.1","crypto-4.5", + {runtime_dependencies, ["sasl-3.0","kernel-9.2","erts-13.1","crypto-4.5", "compiler-5.0"]} ]}. -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor